Moles and SharePoint Behaviour types

给你一囗甜甜゛ 提交于 2019-12-20 02:28:54

问题


We are having problems with the following code:

        BSPSite site = new BSPSite();
        BSPWeb web = site.SetRootWeb();

The error is : Could not load file or assembly 'System.Moles, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0ae41878053f6703' or one of its dependencies. The system cannot find the file specified.

We have tried rebuilding the Behavoir assembly in the source code to .NET 4 but that didn't go through. We are using v0.94.

Any help would be appreciates.


回答1:


1) Go to C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies

2 ) Find Microsoft.Moles.VsHost.x86.exe.config

3) Open and alter by adding next lines under runtime

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
           <dependentAssembly>
                     <assemblyIdentity name="System.Moles" publicKeyToken="0ae41878053f6703" culture="neutral"/>
                     <bindingRedirect oldVersion= "4.0.0.0"
                                              newVersion= "2.0.0.0"/>
            </dependentAssembly>

     </assemblyBinding>



回答2:


Delete all the .moles related files and the .moles references.

Then add the Moles reference for each of the assemblies (right click on the original assembly under References and select Add Moles Reference). This will make the .dlls regenerate for the new Moles version.



来源:https://stackoverflow.com/questions/5975474/moles-and-sharepoint-behaviour-types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!