I have a .net 3.5 dll and a .net 4.0 dll. The .net 3.5 dll need to call some functions in the .net 4.0 dll. To do this, I made the 4.0 .net dll as a COM server. However, I cannot tlbimp the tlb file exported from the 4.0 dll. Is it possible for a .net dll to call functions from a .net CO开发者_C百科M server? Thanks.
If possible you should either upgrade the 3.5 to 4.0 or downgrade the 4.0 to 3.5/2.0, so you can properly add the managed reference.
If you can't do that the alternative is to copy the declaration and replace [ComVisible(true)] by [ComImport] - however this may fail with a typecast exception on runtimes earlier than 4.0. I don't know if it works when 3.5 talks to 4.0, you'd have to test.
精彩评论