开发者

How to late bind a CLR 4.0 assembly from a 3.5 project?

The title is self-explanatory of what I want to accomplish. I have a COM-visible component built in 3.5 and my new projects are 4.0. Code very similar to the one below is what I want to run from the 3.5 component.

        Assembly a = Assembly.LoadFrom(@"C:\MyCLR4.exe");
        Type t = a.GetType("MyCLR4Class");
        object o = Activator.CreateInstance(t);

Ultimately I'm getting the error "This assembly is built by a runtime newer than the currently开发者_StackOverflow中文版 loaded runtime and cannot be loaded"

I'm pretty discouraged by what I've found elsewhere. All I need is a workaround to accomplish this. Thanks!


I give up. This simply cannot be done without making some serious compromises and various hacks with the GAC and COM registration as pointed out by Tony Lee (thanks for the links). I ended up rebuilding everything in 4.0.

Paraphrasing A. Einstein: ".NET is well and good but Microsoft keeps dragging us around by the nose"

:)

Thank you all for the comments and help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜