|
nwein
Posts: 577
Joined: 2011-03-28
|
I've noticed that when clicking on the context menu of an ADX project and selecting either Register or Unregister ADX Project it triggers a rebuild of the project as opposed to plain build.
Is there a reason why the project needs to be rebuilt? I'm asking as I have another project that keeps being locked by VS whenever I do rebuild which forces me to close and re-open VS every time I rebuild (other than the first time of course). |
|
Posted 10 Dec, 2012 16:27:30
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 19011
Joined: 2006-05-11
|
Nir,
What Visual Studio version are you using?
Do you refer the other assembly via Add Reference/Projects? Or via Add Reference/Browse? What value do you have for the Copy Local property of the reference?
Do you create an instance of a class from other assembly in the constructor of the add-in module or in class-level initializers?
Does any class in your add-in project implement an interface defined in the other project?
Do you register/unregister the add-in really often?
Andrei Smolin
Add-in Express Team Leader |
|
Posted 11 Dec, 2012 09:29:51
|
|
Top
|
|
nwein
Posts: 577
Joined: 2011-03-28
|
Thanks for the multi-question reply :)
What Visual Studio version are you using? Visual Studio 2010 Ultimate (ADX 2010.6.7.3062)
Do you refer the other assembly via Add Reference/Projects? Yes
Or via Add Reference/Browse? No
What value do you have for the Copy Local property of the reference? True (i.e. copy local), if I set it to false I don't have rebuilding problems but then any modified code in the latter assembly won't reflect in the add-in.
Do you create an instance of a class from other assembly in the constructor of the add-in module or in class-level initializers? That's a good question I never thought of. I am instantiating some objects from that assembly (though most of it is static), not in the constructor (I leave it untouched as per you guys and per me getting burned on this... :)), but in the initializers for sure.
Does any class in your add-in project implement an interface defined in the other project?
Probably.
Do you register/unregister the add-in really often? No, which is a good thing for me :) but I do have to do it every once in a while especially after deployment and platform target changes (Debug/Release etc.) |
|
Posted 11 Dec, 2012 10:22:25
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 19011
Joined: 2006-05-11
|
Nir,
If the issue occurs even if you just rebuild the project (not register!), then you should modify your add-in project so that it does NOT create an instance of a class defined in the other assembly in class-level initializers.
nwein writes:
Does any class in your add-in project implement an interface defined in the other project?
Probably.
Can you please provide a definite answer?
Andrei Smolin
Add-in Express Team Leader |
|
Posted 12 Dec, 2012 11:28:16
|
|
Top
|
|
nwein
Posts: 577
Joined: 2011-03-28
|
Thanks for the reply Andrei.
The issue is of course when rebuilding the ADX project. Registering/Unregistering only manifests the issue and that was more of my question - why does registering requires rebuilding and not just building?
Nonetheless, if I could resolve that locked reference it would be even better, therefore I'll review my code and attempt to see if I can move any instantiation from the initializers.
What about static classes though? I do use those (without of course initializing them).
Quick question - when you refer to initializers do you mean only the AddinInitalize event (I have it on both XLL and COM add-ins, not in RTD though)? What about AddinFinalize or other events?
As for implementing the other project's interfaces in my add-in project - I don't have direct implementation anywhere (i.e. MyClass : InterfaceFromOtherProject) but I am using implemented interfaces defined in the other project (and in many other projects for that matter).
I am directly implementing some interfaces in my ADX project though they are not from the other library (e.g. my RTD class inherits from ADXRTDServerModule and also implements IRtdServer, also I'm implementing some IDisposable in the ADX project). |
|
Posted 12 Dec, 2012 11:57:21
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 19011
Joined: 2006-05-11
|
Nir,
When you register the add-in, the code which actually registers the add-in needs to have the latest version of the assembly which includes all code modifications. This is why Add-in Express rebuilds the project.
Initializers. See below.
I reproduce the issue in this scenario:
1. I have a class library
namespace ClassLibrary1
{
public class Class1
{
}
}
2. In the add-in module I define a variable of the ClassLibrary1.Class1 type and initialize it (this is an inializer):
namespace MyAddin335
{
public class AddinModule : AddinExpress.MSO.ADXAddinModule
{
private ClassLibrary1.Class1 myObject = new ClassLibrary1.Class1();
//...
}
}
3. Rebuilding the project works. Registering the add-in works. Rebuilding after registering produces the issue: the assembly is locked.
That is, if a class is defined in another assembly, then creating an instance this class while the module is created, loads that assembly. This is why we don't recommend modifying the constructor of the add-in module. Note that initializers are executed even before the constructor!
Andrei Smolin
Add-in Express Team Leader |
|
Posted 14 Dec, 2012 06:40:03
|
|
Top
|
|
nwein
Posts: 577
Joined: 2011-03-28
|
Thanks for the detailed response, it makes sense now. |
|
Posted 14 Dec, 2012 07:02:51
|
|
Top
|
|