Author Topic: Building your add-in. DLL file doesn't update.  (Read 10530 times)

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Building your add-in. DLL file doesn't update.
« on: February 21, 2015, 09:03:22 pm »
This is hard for me to explain cause I'm not completely sure of what the problem is and what is causing it.

I've worked on my EA add-in for a couple of months and I got this problem that keeps returning to me.

Anyway I've setup the add-in as Geert Bellekens describes in this link:
http://bellekens.com/2011/01/29/tutorial-create-your-first-c-enterprise-architect-addin-in-10-minutes/

So when I compile it should update the DLL file in windows assemblies. But sometimes when I compile Visual Studio doesn't update the add-in. I think it's something with the COM codebase that goes wrong but I'm not sure.

Anyway I can't seem to figure out why this problem appears and I've solved it a couple of times without knowing how I did it and maybe that's why it keeps coming back.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #1 on: February 22, 2015, 12:36:41 am »
Just a guess: EA must be closed. Else the DLL is locked.

q.

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #2 on: February 22, 2015, 09:05:54 am »
Hi

As q says the fact that DLL doesn't appear to updated is often caused because the existing DLL is locked, and a warning message from the IDE is missed when it tries to copy the new version.

I've experienced many funnies over the years with creating addins - often due to an oversight on my part or sometimes just being careless trying to do too much at a time!

From what you describe, i.e. you expect the compile to do the update of the codebase, it looks like you are building and testing using the AddIn from you IDE and not running installing it with an msi.

In that case my check list would be:

1. Check that your compile settings for your DLL include "Register for COM interop" - otherwise the IDE will not register your compile DLL with the codebase in the windows registry.

2. Check that the compile completes OK and there are no warnings about being able to copy the file - otherwise you will continue to use a pre-existing DLL.  

3. Run my EA Installation Inspector - http://community.sparxsystems.com/community-resources/772-ea-installation-inspector - a free download from community site.  This was developed to help with a range of AddIn installation issues and will give you the name and location of the DLL that is linked to the AddIn.  Check:
  • DLL file name and location are correct
  • date/timestamps match those of the DLL you have created

For more background on EA and how it finds your AddIn you may find it useful to check out a recent post of mine which looked at missing AddIn's - http://exploringea.com/2015/01/19/one-of-our-add-ins-is-missing/ - but outlines the mechanism and so will apply to accessing the wrong DLL as well.

If that doesn't solve your issue please provide more information on development tools used and I'll try and help.

Adrian
« Last Edit: February 22, 2015, 09:09:02 am by MrWappy »
EXploringEA - information, utilities and addins

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #3 on: February 24, 2015, 05:26:23 am »
@Qwerty:
That's not the case and even if it was the case visual studio would warn that it is locked in another process.

@MrWappy/Adrian:
I've checked the "Register for COM interop" and all that other stuff.
I will try to describe it further and maybe that will give you a more clear insight.

I have had it working for months with compiling updating the AddIn. The problem occurred to me yesterday while working on a feature. I didn't change anything in the solution settings or anything and out of nowhere it just stopped working when I compiled.
This has happened a couple of times and I don't have a clue of how I solved it the last times. It's like one of these problems which just comes and goes.

I've also tried with an .msi installer but that doesn't work either - it has worked before. I can see the key in windows registry (Assembly.Class). I can see that the AddIn status in EA is "missing". I can see that the compile completes without any errors.

It seems like Visual Studio has lost the "ability" to register my compile DLL with the codebase :s

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #4 on: February 24, 2015, 06:28:12 am »
Interesting!!

Have you changed accounts? To one that does not have admin rights?

Without access to tinker my suggestions would be to:

1. Use the installation inspector to see what DLL it thinks is registered - from what you say this should confirm that your latest DLL is the NOT the dll that is registered.  This should confirm that the error code you have for the missing DLL.  

2. Manually register your DLL - check with the inspector that the DLL NOW exists ( the command to do this in the post I reference before),  and also check it works correctly with EA.

If that works as I think we have eliminated problems outside of your IDE  o a few further checks in no specific order:
* Can you confirm that you are running VS as administrator?  without which VS may, depending on your OS and config, be able to register the DLL.

* Look into the project file and check for your current configuration that the RegisterForCOomInterop is set True - see extract of an addin project file below:

Code: [Select]
 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <OutputPath>..\..\..\..\..\..\..\Program Files %28x86%29\E001_ASimpleEAMenu\</OutputPath>
    <DocumentationFile>E001_ASimpleEAMenu.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
    <RegisterForComInterop>true</RegisterForComInterop>
  </PropertyGroup>


If not then set it manually in the project file and repeat your test.



If the manual register did not work then let me know and I'll think about some other tests.


« Last Edit: February 24, 2015, 06:29:29 am by MrWappy »
EXploringEA - information, utilities and addins

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Building your add-in. DLL file doesn't update.
« Reply #5 on: February 24, 2015, 06:13:56 pm »
You could also try to compile and register your add-in with Sharpdevelop, just to be sure it isn't VS related.

Geert

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #6 on: February 24, 2015, 07:52:06 pm »
My company isn't very fond of installing a lot of help tools (like installation inspector and sharpdevelop) so atm this is not an option for me - which I personally dislike.

I can see in vs and I've double-checked the proj file to see that RegisterForCOMInterop is set to true. I've also checked that the assembly is set to Make Assembly COM-Visible. So this should be the right configuration from vs.

When I compile I can see that the dll in the bin\debug folder is getting updated but when I look in the windows\assembly\GAC_MSIL and find where my dll is located it is not updated. Does this have anything to do with it?
I do not know very much about this topic and how it works.

I've checked the regedit to see if the key is there and it is.

Should I try to register it manually with regasm?


Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #7 on: February 24, 2015, 08:40:53 pm »
Here is some further information of what I tried:

I removed key in regedit and made sure that the AddIn was uninstalled (if I had installed it earlier from a msi installer).
Then I installed the latest version of the msi which I knew has worked before and it was still working. So I tried to go back to vs and compile with the registerforCOM and make COM-visible settings and it didn't change anything - the AddIn in EA was still working. So there must be a missing part there.
I chose EA as my startup project (start external program), compiled, started debugging and then the AddIn went missing again.
However when I stopped debugging and opened EA outside vs the AddIn was there again.

I've also tried to debug the latest installed addin with attach to process and it won't hit any breakpoints which makes sense.

So for me it seems like vs and EA has lost their "connection".
« Last Edit: February 24, 2015, 08:51:21 pm by Stenvang »

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #8 on: February 24, 2015, 09:00:44 pm »
Understand issue of installing code - you can just run the installation inspector - no install required. It can save a lot of time checking through the registry - but the process can be done manually.

A bit short of time to review at present - but would suggest you try the manual register and test as that removes VS for the process.  And it seems like you need to isolate the "thing" that is causing the issue.

Adrian

Forgot to add that assuming all goes well, VS registers the DLL that is in your debug folder when your are debugging; it doesn't overwrite any installed version of your DLL.   When you end (assuming VS doesn't crash) the registry entry will be reset to the installed class.
« Last Edit: February 24, 2015, 09:06:51 pm by MrWappy »
EXploringEA - information, utilities and addins

philchudley

  • EA User
  • **
  • Posts: 743
  • Karma: +21/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #9 on: February 24, 2015, 09:14:06 pm »
Try starting Visual Studio as

[highlight]Run as Administrator[/highlight]

and ensure that EA is not running

Cheers
Models are great!
Correct models are even greater!

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #10 on: February 24, 2015, 09:41:12 pm »
Good point - although already suggested it is an absolute must, so worth emphasising to make sure it's double checked.   Especially if you are relying on shortcuts - which could well get modified - and in view of the observed change in behaviour, don't assume anything.
« Last Edit: February 24, 2015, 09:45:27 pm by MrWappy »
EXploringEA - information, utilities and addins

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #11 on: February 24, 2015, 11:22:14 pm »
Hi all,


Just my två öre's worth here, but I feel very strongly that using Visual Studio's Register for COM Interop feature is a Bad Idea (TM). You are far better off creating an installer.

Simply put, creating an installer is the proper way of doing it, using Studio's auto-register feature is the hacky way. Which is fine, I guess, if you're just doing something small intended for your own personal use and don't mind a bit of bit rot on your development machine.

Putting together a WiX installer for an EA Add-In isn't hard, but if you've never done it before it can seem a little daunting. Which brings me to my question.

A while back, I started on a Visual Studio solution template for EA Add-Ins. I kinda lost interest, didn't see much of a market for it, but I can finish that up and post it to the community if there's any interest.

Is there?

Cheers,


/Uffe

PS I am well aware that the COM registration issue is nothing to do with file locks and admin privileges. But since it was brought up in the thread I thought I'd take the opportunity to smack it down.
My theories are always correct, just apply them to the right reality.

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #12 on: February 25, 2015, 01:31:09 am »
Uffe

Yes using an installer is best, however during the development you don't need to go through the process of creating an installer until it is stable and/or ready to deploy to users.

As you state it's not too difficult, there are plenty of tutorials on creating a Wix installer, but some are confusing and may not relate well to the needs of an addin developer. For me it was remembering which stuff to include and where.  Like you I soon produced a template that I use for creating virtually all my addins and their installers which is really useful, not least as a check list of what to include/where.  However, I also saw little demand for AddIn or installer "helper" products - I even started writing a book on addins about 3 or 4 years ago but my interest waned when I saw there probably wasn't a market, so just keep a private wiki iof useful stuff instead.

Coming to the point you make about com registration and admin is interesting.  I'm not a windows OS expert (too new an OS for me!) but had assumed that to make changes to the registry (at least in Win 7 onwards with GAC) you need admin rights.

It may be wrong or specific to my system(s), but I've seen some issues with VS when it hasn't been running as admin and failing to register a DLL.  So worried that I imagined it I've just rerun a test (as a normal i.e. non-admin user), and on building one of my AddIns I got an error message:

Code: [Select]
Error 44      Cannot register assembly "C:\Users\NormalUser\Documents\Visual Studio 2012\Projects\eaForms81439\eaFormGenerator\bin\x86\Debug\eaFormGenerator.dll" - access denied.
Please make sure you're running the application as administrator.

I remember this situation changed when I moved from XP to Win7.  I had always assumed it was a consequence of how the OS GAC is configured.  Never really explored it further, so just accepted I needed to ensure that EA wasn't running and I ran VS as administrator before I built my solutions.

Of course, my observations may not be typical, but I do feel there is more to it other than it isn't an issue of privileges or locks.  Unfortunately it would take some time to understand all the rules and if there is an easier way....

As one of my colleagues always reminded me years (decades) ago "always work at the lowest possible privilege level" - but that also means spending time working out what is essential and what is nice to have. Easy just to work as an admin user. :)

Finally, coming back to the original reported issue,  Stenvang hasn't indicated any error messages - so I would have initially discarded the saving of the DLL more about where the registry thinks the class is linked.  So  think getting the key information from the registry to see the mapping between EA and the class and the linked DLL file is key to getting a clearer understanding of the issue.

Adrian



« Last Edit: February 25, 2015, 08:00:19 pm by MrWappy »
EXploringEA - information, utilities and addins

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #13 on: February 25, 2015, 10:05:18 am »
Could be a longshot, but do you have MDG Integration for Visual Studio installed?  If so, there could be an EA.exe process running in the background locking the dll.  I know I've run into that before when trying to compile an add-in.  Open the Windows Task Manager and look in the Processes tab (not the Applications tab) to confirm there are no instances of EA.exe currently running.

Stenvang

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: Building your add-in. DLL file doesn't update.
« Reply #14 on: February 26, 2015, 03:32:31 am »
Okay so I solved the problem!

And it was nothing near what I thought it was...

My feature was parsing through elements and I had a LastElement attribute to keep track of the latest parsed element. However I had initialized the LastElement attribute to new Element(); - so I was constructing an EA interface during the construction of the AddIn which caused the dll to be broken - EA doesn't like that.