开发者

Exception: "The assembly used when compiling might be different than that used when loading and the type is missing."

开发者 https://www.devze.com 2022-12-20 22:50 出处:网络
I am building a Prism app with several modules, one of which (MyModule) contains a user control (MyUserControl) that I created. MyUserControl tests fine, but when I add it to MyModule and run the app,

I am building a Prism app with several modules, one of which (MyModule) contains a user control (MyUserControl) that I created. MyUserControl tests fine, but when I add it to MyModule and run the app, I get this exception:

"Cannot find type MyUserControl. The assembly used when compiling might be different than that used when loading and the type is missing."

I can fix the error by adding a reference to MyUserControl to my Shell application. But of course, that defeats the whole purpose of Prism, since the Shell does not use MyUserControl--only MyModule uses it.

MyUserControl is based on the WPF Calendar control from the WPF Toolkit, which seems to have a similar pr开发者_Go百科oblem. I have another user control in another module that does not depend on the WPF Toolkit, and I don't get this exception for that control.

Any suggestions on how to fix this problem without coupling the Shell to MyUserControl? Thanks.


I think what you need is just copy the MyUserControl.dll once built into the main app folder (adding a reference in your main app is just doing that) the simplest way of doing that is using a post build event. right click on MyUserControl project , select properties, select the "Build Events" tab, in the Post-build command line type: xcopy $(TargetFileName) $(SolutionDir)\YOUR MAIN APP FOLDER\bin\Debug\Modules\ /Y and that's it, once MyUserControl is built it will be copied into the main app folder automatically, then when you run the app the module that uses it will be able to find it.

0

精彩评论

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

关注公众号