DependenciesSearchPaths problem. ( May I say a bug? )

OgnyandimOgnyandim Posts: 16
edited January 31, 2013 8:30AM in SmartAssembly
Hello,
Here is the situation :
I have two projects - the first is a simple AutoCAD 2012 plug-in ( .dll ) and the other is the same simple plug-in but for AutoCAD 2013. The two dlls are using the same source code - I link 2012 code into 2013 project - that is because Autodesk decided to move things around in the dlls - AcMgd.dll, AcDbMgd,dll, AcCui.dll in AutoCAD 2012 and one more in AutoCAD 2013 called AcCoreMgd.dll. The problem comes with a specific collection which is now in extension class.

At the end I have two projects in the same solution, the second just links the code of the firsts and has almost the same references. I ave two .saproj-ects too.

Where is the problem you should ask?

The problem is that I am building these two dlls in separate project files ( .saproj ) and when I try to obfuscate them the first project created gets done and the other does not. SmartAssembly displays an error :
SmartAssembly has encountered an invalid symbol
[Acmgd]
Autodesk.Autocad.ApplicationServices.DocumentCollectionExtension

The most likely cause is that SmartAssembly has used a different version of dependency from the version used by acadPlugin2013.dll.

If the details below are wrong, please use the mandatoryPath attribute in the .saproj to ensure that the correct version of the dependency is found.

Assembly that should contain the symbol :
[deleted]..\objectarx.2012\Acmgd.dll

And surely it does display a good error message. Look back there - "objectArx.2012"!! - I have just made a brand new .saproj and selected object.arx.2013 folder not 2012 folder when I was prompted for the dependencies of my dll.

Where is the problem? - In the fact that SA writes its dependency search folders in "C:\ProgramData\Red Gate\SmartAssembly\SmartAssembly.settings" in the <DependenciesSearchPaths> section. Why is that a problem you should ask? Because this is not a per project section but a global section that sticks to SA and not the project. And why is that a problem? Because the firs project gets "instrumented" by SA with its assemblies and for the other I get the error because the associated assemblies are not its own but these from the previous project. Even I have selected different dependency during code analysis! Why is that? I thing it is because SA looks its search paths first and stops when it finds the .dll with the specified name. But that is the wrong dll. I am asking - Why is that behavior? Why SA prompts me for a dependency and then it gets its own from its search path?
<DependenciesSearchPaths>
<SearchPath>[some_path]\my_lugin\libs</SearchPath>
<SearchPath>[some_path]\my_lugin\libs\objectArx.2012</SearchPath>
<SearchPath>[some_path]\my_lugin\libs\objectArx.2013</SearchPath>
</DependenciesSearchPaths>

And now SA finds the AcMgd.dll in the first folder, but we need the second folder, and brings it in and BANG - dependency error as displayed above.

"Have you tried setting "MandatoryPath" property in your 2013.saproj file in order to tell SA where to get the dependency explicitly as recommended by the error message?" - Yes, that was the first thing I have done as explained here http://www.red-gate.com/supportcenter/content/SmartAssembly/help/6.7/SA_SearchingForDependencies:
<Assembly AssemblyName="Acdbmgd, Culture=neutral, PublicKeyToken=null" MandatoryPath="..\..\..\libs\objectArx.2013\AcDbMgd.dll">
<Merging />
<Embedding />
</Assembly>
<Assembly AssemblyName="AcCui, Culture=neutral, PublicKeyToken=null" MandatoryPath="..\..\..\libs\objectArx.2013\AcCui.dll">
<Embedding />
<Merging />
</Assembly>
<Assembly AssemblyName="Acmgd, Culture=neutral, PublicKeyToken=null" MandatoryPath="..\..\..\libs\objectArx.2013\AcMgd.dll">
<Merging />
<Embedding />
</Assembly>
<Assembly AssemblyName="AdWindows, Culture=neutral, PublicKeyToken=null" MandatoryPath="..\..\..\libs\objectArx.2013\AdWindows">
<Embedding />
<Merging />
</Assembly>
<Assembly AssemblyName="AcTcMgd, Culture=neutral, PublicKeyToken=null" MandatoryPath="..\..\..\libs\objectArx.2013\AcTcMgd">
<Merging />
<Embedding />
</Assembly>
<Assembly AssemblyName="accoremgd, Culture=neutral, PublicKeyToken=null" MandatoryPath="..\..\..\libs\objectArx.2013\AcCoreMgd.dll">
<Merging />
<Embedding />
</Assembly>
[\quote]
Does it look good now? Yes, but there is something missing here - a fresh new restart of SmartAssembly. This is the point in the post when decided to try restarting it before posting. :) I needed to restart SA and not just edit it. I edited the .saproj, but it looks like it is in the memory of the application - body told me so, neither does the error message but I guessed it and everything runs runs now.

Why SA prompts me for the dependencies of my DLL in the beginning when the code analysis happens and when I point AcMgd.dll in objectarx.2013 folder everything is great and code analysis passes and after that when I press Build SA searches in its own prerecorded folders for my previous project and not the exactly selected DLL?

A good idea is to make the DependenciesSearchPaths attribute per project and not global
in order to reduce "friction".

P.S. I really like SA and I admire the good work done on it. It saved me months in which I would have to reinvent the wheel.

Comments

  • Thanks for your post- normally, yes, we would say to use MandatoryPath in the .saProj.

    I wasn't quite sure about the part where this went wrong - when you say a fresh restart of Smartassembly, do you mean with a new project, so you have to do MandatoryPath all over again? Or the changes you made to your project got lost?
    Systems Software Engineer

    Redgate Software

  • Hello :)
    It went wrong during build. By fresh restart I mean that I closed SA and then started it. Before restarting any editing - say including of MandatoryPath - were not taken into account. Probably closing and then opening again would have done the job too, but I am not sure. I restarted it. After restart the changes were considered and the build went good.
  • Ahh, I see- so basically, you made changes to the .saProj while Smartassembly was running, but it did not see the change until re-loaded?
    OK, that makes sense.
    Systems Software Engineer

    Redgate Software

Sign In or Register to comment.