josh's WebLog

Visual C++ IDE from the trenches

feedback: assembly references and paths

in feedback on my last post, Stephane asks about assembly references and shareable paths in csproj and vcproj files.

c# projects in VS 2002 and 2003 store in the project file a path that is relativized to the project directory. this is called the 'hint path', if memory serves. also, in the .user file for the project (a file intended only for the particular user, not to be shared or checked into source code control) the directory of the reference is stored. as long as all references can be relativized to a shareable location this works. the path cannot be edited in VS and macros cannot be used.

in VC projects in VS 2003 assembly references work slightly differently and have many shortcomings. IIRC a relative path is stored, as in C#, and you cannot control the paths or set them to use macros. my recommendation is to use the project system support for /FU and /AI rather than adding "references". the one time when this is not possible is when you need to use the "designer" (visual form editor). because of the internal workings of the designer it requires you to use references. the support for references will be much improved in the upcoming release of VS.

i'm not quite certain about the last part of Stephane's question, regarding CLSIDs and PROGIDs of assemblies. assemblies are managed entities that don't require CLSIDs or PROGIDs unless they are registered for COM interop. I believe the designer loads the assemblies via a managed call to Assembly::LoadFrom, while at runtime the .NET loader does something similar to Assembly::Load.
Published Monday, February 09, 2004 1:14 PM by josh_

Comments

 

Stephane Rodriguez said:


Thanks for the answer.

I think we haven't understood each other well, so let me rephrase :
- the vcproj and csproj project file formats pay a different attention to references components, for instance when you insert an ActiveX component onto a dialog (C++) or a form (C#). The vcproj project file won't even keep track of whether an ActiveX has been added, leaving plenty of rooms for deployment issues. The csproj project, however, keeps track of the ActiveX (Build / References / Reference / guid= ...), essentially because it has to use a combination of tlbimp and aximp in order to interop the type-library before it's seen like a regular assembly. At this point, the question is : why do the two projects have a different view on those references? The language you are using does not change anything to the fact that an ActiveX has to be preinstalled on the client machine in order for the app to work, regardless it's written with C++ or C#, so using C++ in this example maximizes the potential of deployment issues, right?
- Wasn't the overhaul of the file formats a chance to solve that kind of issues, and provide consistency across file formats? Quite honestly, I don't understand. Microsoft has been changing the file format in 7.0, 7.1 and is probably changing it again in Whidbey (msbuild, ...), but I am not sure at all that it solves the typical developer issues that we face, especially deployment.
- if you insert an ActiveX component into a .rc dialog, then the clsid of that ActiveX is referenced there. Unfortunately, this clsid is only taken care of at run-time when the dialog loads the controls, and the app will fail miserably if the clsid does not exist. Why isn't there a dependency checker at design-time? That said, why isn't the prog id referenced and used instead or as well of the clsid? Isn't the independent version progid meant to solve deployment and versioning issues? Why isn't VS.NET helping developers in this regard? Let's take an example : I develop a sample app using Windows Media player 6.4, and it runs on Windows 2000. Now I want this app to work on Windows XP. How can I know whether the app works at all? If the app references an independent version progid, then even if Windows XP does not have Windows Media player 6.4 preinstalled, it can start say Windows Media player 8.0, so my app works. But if we use clsids, chances are the app works only on Windows 2000.
- regarding shared paths. You have mentioned relative paths (hintpath), that's right. But because you have also said it's not possible to use macros on the one hand, and there is no direct support for that in the IDE, then it's simply not possible to do teamwork, unless you are in a special case : all source code under a single branch tree (is that realistic and fair?). Indeed, the relative paths raises issues as soon as my branch is installed on say C:\Dev and not the whole source code is put in subfolders, while my coworker's branch is D:\Version5\Source. Files references with relative paths will be ok on my machine, not his, and vice versa. The question is : have you introduced anything in Whidbey to solve this or at least try? clsids?
February 10, 2004 3:15 AM
 

josh s WebLog feedback assembly references and paths | Insomnia Cure said:

June 9, 2009 9:02 PM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker