.NET 1.1 Project With File-Based Reference To A .NET 2.0 DLL Not Working
All--
Please help
I have a design that requires that a given .NET 1.1 WindowsForms client application must include a file-based reference to a DLL that was built with .NET 2.0. Unfortunately, I cannot get it to work. The VS.NET 2003 IDE will simply not let me add the reference. Ug. I have tried several tests, detailed below, but I have yet to find an answer.
Can it be done?
If yes, then how can it be done?
If no, then what is the work-around?
What do you think?
Please advise.
-------------------------------------------------------------------------------Overview: In in a .NET 1 project, try adding a file-based reference that points to a DLL that was created with .NET 2.
----------
Test 1: Standard DLL
When trying to add a standard, .NET 2, class-library, DLL as a file-based reference, the following design-time error appears...
A reference to 'C:\projectsEx\TestDotNet2Dll\bin\Debug\TestDotNet2Dll.dll' could not be added. This is not a valid assembly or COM component. Only assemblies with extension 'dll' and COM components can be referenced. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
----------
Test 2: DLL With MakeAssemblyComVisible=True
>Project, >Properties, >Application, >Assembly Information, >Make Assembly COM-Visible
When trying to add a MakeAssemblyComVisible=True, .NET 2, class-library, DLL as a file-based reference, the following design-time error appears...
A reference to 'C:\projectsEx\TestDotNet2Dll\bin\Debug\TestDotNet2Dll.dll' could not be added. This is not a valid assembly or COM component. Only assemblies with extension 'dll' and COM components can be referenced. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
----------
Test 3: DLL With RegisterForComInterOp=True
>Project, >Properties, >Compile, >Register For COM Interop
When trying to add a RegisterForComInterOp=True, .NET 2, class-library, DLL as a file-based reference, the following design-time error appears...
A reference to 'C:\projectsEx\TestDotNet2DllWithRegisterForComInterOp\bin\Debug\TestDotNet2DllWithRegisterForComInterOp.dll' could not be added. This is not a valid assembly or COM component. Only assemblies with extension 'dll' and COM components can be referenced. Please make sure that the file is accessible, and that it is a valid Assembly or COM component.
-------------------------------------------------------------------------------
Thank you.
--Mark Kamoski
Answers
Using COM Interop won't work because even if it uses COM for "interoperating" it still needs the .NET Framework to run. Since you cannot load 2 versions of the .NET Framework in the same process it will end up running against .NET 1.1 and fail.
Now what other options you have it really depends on the reason you want to use that .NET 2.0 assembly in a .NET 1.1 application and what that assembly does.
1) If the reason is that you want to deploy your application on machines that don't have .NET 2.0 installed then it will never work. Period.
2) If you just need to use VS2003 then you can try to use a configuration file to make the application use .NET 2.0 and use Assembly.Load and reflection to access that assembly. Obviously this is tedious and does not qualify as a "file based reference". Also you won't be able to debug it using VS2003 because it cannot debug a .NET 2.0 application. I also tried to export a type library from a .NET 2.0 assembly and add that as a reference but it does not work either. Even if it would have worked the above about configuration file to make the application use .NET 2.0 instead of .NET 1.1 and not being able to debug it using VS2003 would still apply.
Somehow I believe 1) is your case since from your post you seem to have both application and assembly source and the 2 versions of Visual Studio.
All Replies
You cannot use a .NET 2.0 assembly with VS2003/.NET 1.1.
Mike Danes wrote: You cannot use a .NET 2.0 assembly with VS2003/.NET 1.1.
I appreciate the reply.
I would like to find more information, if possible.
Are you sure that there is no way to do it?
What about COM-InterOp?
Do you have any links to any documentation on the matter?
Please advise.
Thank you.
--Mark Kamoski
Using COM Interop won't work because even if it uses COM for "interoperating" it still needs the .NET Framework to run. Since you cannot load 2 versions of the .NET Framework in the same process it will end up running against .NET 1.1 and fail.
Now what other options you have it really depends on the reason you want to use that .NET 2.0 assembly in a .NET 1.1 application and what that assembly does.
1) If the reason is that you want to deploy your application on machines that don't have .NET 2.0 installed then it will never work. Period.
2) If you just need to use VS2003 then you can try to use a configuration file to make the application use .NET 2.0 and use Assembly.Load and reflection to access that assembly. Obviously this is tedious and does not qualify as a "file based reference". Also you won't be able to debug it using VS2003 because it cannot debug a .NET 2.0 application. I also tried to export a type library from a .NET 2.0 assembly and add that as a reference but it does not work either. Even if it would have worked the above about configuration file to make the application use .NET 2.0 instead of .NET 1.1 and not being able to debug it using VS2003 would still apply.
Somehow I believe 1) is your case since from your post you seem to have both application and assembly source and the 2 versions of Visual Studio.
Mike Danes wrote: Using COM Interop won't work because even if it uses COM for "interoperating" it still needs the .NET Framework to run. Since you cannot load 2 versions of the .NET Framework in the same process it will end up running against .NET 1.1 and fail.
Now what other options you have it really depends on the reason you want to use that .NET 2.0 assembly in a .NET 1.1 application and what that assembly does.
1) If the reason is that you want to deploy your application on machines that don't have .NET 2.0 installed then it will never work. Period...
...
...Somehow I believe 1) is your case since from your post you seem to have both application and assembly source and the 2 versions of Visual Studio.
I really appreciate the details.
You are right-- the goal was (1). Some endusers may not have .NET 2.0 due to the corporate lag-time in the rollout of .NET 2.0 to the corporate desktops. That's another sad story. I mean-- how hard is to have everyone simply go to the Windows Update site and get .NET 2.0? A monkey could do that. Ug. Don't get me started. Anyway, now I have a business case to revisit the architecture.
I want to make the client UI a .NET 2.0 web-based application, rather than a .NET 1.1 WindowsForms-based application. That way, the impact of the "must have .NET 2.0 installed" requirement will only apply to the deployment location of the .NET 2.0 web-based application and everybody can connect with any browser they want. And so on. Unfortunately, there are some who are demanding a WindowsForms client-- but, maybe they can be convinced otherwise given this excellent information that you have provided.
Luckily, we are just talking about the UI client application. The GUI (web-based or WindowsForms-based) simply hooks up to web-services so everything other than the UI is .NET 2.0; so, at least we are living in the modern-world there.
On with the show!
Thank you.
--Mark Kamoski


