Intellisense does not work with "compiled" assemblies
- Hello. I have a following configuration:
- first project is executable C#.NET windows application
- second project is C#.NET class library
The first project is dependent on the second. The second project does not have code but two copies of the "compiled" assembly: a debug copy and release copy.
I have a script for Post Build processing which copies a correct copy to the output folder of the project.
Now, if i make dependency between projects then in the first project i do not get help from Intellisense for objects of the second project. If i make dependency to the "physical" assembly in the output folder then everything works.
How i can force Intellisense to support this dependency as a project dependency?
Answers
If you didn't have any XML files originally then you will not get documentation now either. Go to your project settings and check the option for generating documentation files. It is on the first tab of the project. This should give you documentation support. However the member information comes from the metadata itself (I believe) so it is not impacted by the project setting.
BTW you should not be copying any files to the bin directory through post-build events. This could very well be messing things up. When you have a reference the build system will automatically copy the dependent assemblies to the appropriate directory (in the general, non-GAC case). It is even smart enough to pick up the dependent's dependents.
And there is a big difference between project and aseembly references. With project references the build system will react to recompilation of the project rather than relying on the generated assembly. With assembly references rebuilding the assembly will not force a recompilation of the dependent assemblies (necessarily). You should prefer project references whenever possible.
Michael Taylor - 4/29/07
There currently is no mechanism to avoid the GAC duplication. Even the framework has to do it.
As for the option it is on the Build tab under the Options group. However I don't believe it is available in the Express version (at least VB.Express) so if you're running that then you won't have the option (I believe).
Michael Taylor - 5/3/07
All Replies
Do you mean you get nothing (such as member names) or no summary information when you select an item? Intellisense uses reflection (I believe) and the generated XML documentation file to build itself. If you don't generate XML documentation files then all you'll get is the member list. The XML documentation file must reside with the binary otherwise Intellisense won't be able to find it. There are workarounds for class libraries that are installed but that is beyond the scope of this posting.
Michael Taylor - 4/26/07
- Yes, I get nothing, no highlighting, hinting or summary info. I did not see any XML files within bin folder of the original project where from i took debug and release assemblies. It also does not explain why if i set a reference to the copy of the assembly which is located in the project and in "Post Build" actions copied into bin folder then i get the full support from IntelliSense, but i do not get it when the reference is set to the project (or more exactly its output)? There is no sense in this difference.
- It seems that we have misunderstanding here. I have a solution with two class libraries. These libraries are shared between other applications in the company. I like to remove projects with the source code of these libraries from other applications' solution files. In order to do it i built assemblies from these projects and created a project per assembly which contains the assembly file itself (DLL). The PostBuild action of this project copy the assembly into Output directory of the project. This way the usual way of sharing things remains but no source code is published. I intentionally did not want forcing people take assemblies from source safe because it is a source of mistakes and does not support Release/Debug building options. Everything is working fine, but i do not get IntelliSense support.
Eventually i selected another way to deal with it by producing a setup file which install these assemblies into GAC and into fixed location which can be referenced from Registry in order to make these assemblies visible in the VS2005 .NET Reference tab.
And i did additional merged module setup that install these assemblies into GAC and can be used in Deployment projects of the application.
This solution is working but has two disadvantages:
1. I lost Release/Debug configuration control
2. It is impossible install assemblies into GAC but put the physical copy into fixed location using VS2005 provided Setup project... In .NET debug/release builds aren't as meaningful as far as class libraries are concerned. You should only put the release builds in the GAC. You also need to generate the XML files. Now for the hard part. VS2005 does not use the GAC for references (ever). This is a common misconception but you can prove it to yourself by looking at the path that VS2005 actually identifies for any referenced assemblies. The problem with the GAC is that it can only store assemblies. PDBs and XML files are not supported. Therefore VS2005 needs to actually use a standard folder for referencing assemblies.
This has already been covered a couple of times in the forums and I've posted an article here (http://p3net.mvps.org/Topics/Basics/IntegratingGACWithVS.aspx) about it so I won't go into details. However if you build a setup to install your assemblies into the GAC and set up the folder structure as mentioned in the article you will get Intellisense support (along with debug support) for your custom assemblies.
As a final aside note that you are not really protecting the source code from anyone. Using reflector (or similar) anybody can see the source code without any effort at all. Even if you use an obfuscator(?) since it is a library you'll still see most of the source code. The only real way to "lock out" the source is to use NGen to compile to native code but I vaguely remember that you still need the IL version in the GAC anyway.
Michael Taylor - 5/2/07
- Under protecting code i meant more development cycle which until now involved taking sources of the library and compiling them for each application which can always cause unnecessary check-outs and accidental code changes. I am aware that even obfuscation cannot really protect the code.
Sad part is that i failed in looking for a checkbox which generates XML file. The Properties page of the project has tabs on the left edge starting from Application tab and ending by Publishing tab. There is no such checkbox on any of them.
Regarding the article i may say that i know the stuff. There is a support link on the Microsft site explaining the same. For development cycle i do install two copies of each shared assembly: one into GAC and another into assembly folder which is visible by VS. This folder will carry XML documentation files once i figure out how i can generate them...
I thought that maybe there is a way to force GAC installation using hardcopy of assemblies from the assembly folder and by this avoid duplication. But this issue is not for this thread... - Found it, thank you. I understand regarding duplication. Will live with it. The only weird thing that it is duplicated in the setup package itself as well as on disk...


