System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Xrm.Client - plugins

I am stuck on this exception already for two days.
I am using MS CRM 2011, and got this exception when I try to register CRM custom worklow activity assembly
1. through pluginregistrator tool,
2. or when I deploy the plugin though package project in Visual Studio and after it run the the workflow, and it stops with waiting status, in the details page giving this expcetion. Here is the detailed exception:
Workflow paused due to error: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Xrm.Client, Version=5.0.9688.1154, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
at ArmenianSoftware.Crm.Spayka.ArmsoftIntegration.Workflows.CreateWorksByPlan.Execute(CodeActivityContext executionContext)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
I am registering assembly on the file system, I have loaded all needed assemblies in the folder %system root%\C$\Program Files\Microsoft Dynamics CRM\Server\bin\assembly. This workflow worked some time, but after I don't know what, next time I deployed the assembly, I got this exception when executing the workflow. This is already third time I am coming across this problem, and spoiling several hours trying to do different things (IIS reset, Async Service restarts, reloading all the assemblies again and redeploying), and after several hours, in a mysterious way, the workflow starts to work. After this works some time, and after some redeployment crashes again. And I can't determine after exactly what steps I solve the problem, and so I spend always several hours on finding out the exception source but to no purpose.
I have looked through some threads in the web but none of them was my case (here are they thread1 , thread2 , thread3)
Have anybody come across this problem? What is the reason of this exception??
Thanks in advance!

I have found the problem in my case!
First thing I have noticed was that the in the Exception the required version of the Microsoft.Xrm.Client assembly was 5.0.9688.1154, but in my project I have the reference to the assembly of version 5.0.9689.1985.
And the next thing was the open ildasm tool, and look what referenced does it have, I opened my custom workflow assembly and I've found that I have two references to Microsoft.Xrm.Client,
first of version 5.0.9688.1154, and the second: 5.0.9689.1985
And a question arose "If I have referenced a assembly the version of wich is 5.0.9689.1985, why there is another version of this assembly? ". And the answer was, definitely, that I had another referenced assembly, which referenced Microsoft.Xrm.Client assembly with version 5.0.9688.1154. I have looked through the assemblies I have reference to in my project. And GOTCHA! In my project I have updated the SDK asseblies to a newer version, but I also had the generated CRM organization Proxy classes assembly, which references Microsoft.Xrm.Client, and I haven't updated this reference to a newer version of CRM SDK. So my custom workflow assembly also needed this version. I changed the references of Proxy dll to newer version, and everything went OK!
If you are reading this post, and you don't have proxy assembly, check your other assemblies, if they all reference the same version of the CRM SDK, if not correct them!
Regards
Gagik Kyurkchyan

Related

SimpleAuthencation throwing "Failed to reflect on the current domain's Assemblies while searching for plugins"

I have a NancyFX web project using SimpleAuthentication that works fine when self-hosting from the terminal. When I self-host from unit tests (NUnit runner with Xamarin Studio), I receive exception "Failed to reflect on the current domain's Assemblies while searching for plugin" with error message "Could not load file or assembly or one of its dependencies." repeated many times.
Any idea why this would fail? This looks like the code throwing the exception is at https://github.com/SimpleAuthentication/SimpleAuthentication/blob/master/Code/SimpleAuthentication.Core/ReflectionHelpers.cs. I tried a IntPtr.Size measurement to make sure they are running in the same 32/64 bitness in both cases (it is running 32-bit).
UPDATE: Per recommendation, I tried to run some prerelease builds to the same resulting, ending up with these binaries:
./Nancy.1.3-Pre1524/lib/net40/Nancy.dll
./Nancy.Authentication.Forms.1.3-Pre1524/lib/net40/Nancy.Authentication.Forms.dll
./Nancy.FlashMessages.1.0.4.0/lib/net45/Nancy.FlashMessages.dll
./Nancy.FlashMessages.Razor.1.0.4.0/lib/net45/Nancy.FlashMessages.Razor.dll
./Nancy.Hosting.Self.1.3-Pre1524/lib/net40/Nancy.Hosting.Self.dll
./Nancy.SimpleAuthentication.0.3.14/lib/net40/Nancy.SimpleAuthentication.dll
./Nancy.Viewengines.Razor.1.3-Pre1524/BuildProviders/Nancy.ViewEngines.Razor.BuildProviders.dll
./Nancy.Viewengines.Razor.1.3-Pre1524/lib/net40/Nancy.ViewEngines.Razor.dll
UPDATE: Running the ReflectionHelpers.cs code in isolation shows that the only DLL failing to load is MonoDevelop.NUnit. The NUnit dll is unneeded for this part anyhow.
I suppose I should contemplate https://github.com/SimpleAuthentication/SimpleAuthentication/issues/144
I fixed this with GetLoadableTypes from this post from #haacked http://haacked.com/archive/2012/07/23/get-all-types-in-an-assembly.aspx/
And here it's the PR (https://github.com/SimpleAuthentication/SimpleAuthentication/pull/171)
I didn't had the problem with Nunit I had the problem with Microsoft.Owin.Security.DataProtection.DpapiDataProtector that it's not implemented in Mono....

WorkFlow designer fails to load in VS 2013

We are using Work Flow's in our project and it is developed in VS 2010. Recently we migrated to VS 2013 Professional. Now when we try to open a Work Flow Activity in VS 2013, we get the following error message:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.SharePoint.WorkflowExtensions, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.VisualStudio.SharePoint.WorkflowExtensions, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'"
We could find the "Microsoft.VisualStudio.SharePoint.WorkflowExtensions.dll" under "C:\Program Files\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\WorkflowDesigner", but still when we open the WF designer, we get the FileNotFound exception.
When we close and open the WF again, we get the below error message :
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.VisualStudio.Activities.EditorPane.set_FileName(String value)
at Microsoft.VisualStudio.Activities.EditorPane.Microsoft.VisualStudio.Shell.Interop.IPersistFileFormat.Load(String fileName, UInt32 formatMode, Int32 readOnly)
Any idea what is causing the issue?
The exception is related to missing Workflow Manager or Workflow Manager Tools on the machine which might not have installed successfully with VS installation at first.
However, you can fix this issue by installing/reinstalling them and dependencies. You might need to restart the machine as well.
Here is the link to download the installers separately: http://www.microsoft.com/en-my/download/details.aspx?id=35375
Looks like we got the root cause now. There were some internet restrictions imposed on the PC's when VS 2013 was installed for which some of the WF related stuffs didn't get downloaded/updated properly.
We tried to re-install VS 2013 without Internet restrictions, and things started to work fine.
Hope this helps someone in need. :)
This worked for me: my workflow was referencing a custom activity I did not have in the /bin folder. Once I placed that custom activity (.dll) into the bin folder, I had no problems.

Build error with PostSharp 2.1.6 (NuGet)

I am evaluating PostSharp for a new project but cannot seem to get past the following error when I first build the project after changes:
Cannot copy file "C:\SourcePath\Output\Debug\MyApp.vshost.exe to
obj\Debug\Before-PostSharp\MyApp.vshost.exe: the file is locked by
process(es):MYAPP.VSHOST (8064)
The error only occurs in the first build attempt. If I immediately re-build, the error does not occur. I can only guess this is because the project isn't actually being rebuilt the second time.
I've read a few posts in the SharpCrafters forum that indicate this problem existed prior to v2.1 but was reportedly fixed. I am using v2.1.6.14 from NuGet (in VS 2010) and getting this error for every project I reference PostSharp. It is certainly not reasonable to require 2 builds every time, so I'm looking for a possible solution. I'm really pleased with what I've seen thus far but will have to go another direction if that can't be resolved.
UPDATE
Per Gael's request, I generated the diagnostic build log and sent it to him and it looks like he was able to resolve the problem in the latest release (2.1.6.14).
I believe part (or all) of the issue may be due to the fact that the build output for all of my projects is set to a common location (i.e. not the /bin/debug folder under each project). This is because we are using a MEF DirectoryCatalog which will discover Imports and Exports contained in the assemblies located in the output path. The PostSharp.targets file has the vshost.exe file excluded from the copy operation but only when it shares the name of the output assembly. In my case, the vshost.exe file has a different name and was, therefore, not being excluded.
The issue has been re-fixed in PostSharp 2.1.6.15.

Webconfig error with the site online

I'm trying to publish a web site.
The publication works perfectly, but when I try to access the address it returns me the following error:
Parser Error Message: Could not load
file or assembly
'Microsoft.Web.Helpers' or one of its
dependencies. This assembly is built
by a runtime newer than the currently
loaded runtime and cannot be loaded.
Source Error:
Line 293:
Line 294:
Line 295: Line 296:
Line
297:
Source File:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\web.config
Line: 295
Assembly Load Trace: The following
information can be helpful to
determine why the assembly
'Microsoft.Web.Helpers' could not be
loaded.
WRN: Assembly binding logging is
turned OFF. To enable assembly bind
failure logging, set the registry
value
[HKLM\Software\Microsoft\Fusion!EnableLog]
(DWORD) to 1. Note: There is some
performance penalty associated with
assembly bind failure logging. To turn
this feature off, remove the registry
value
[HKLM\Software\Microsoft\Fusion!EnableLog].
This does not happen when I'm running on the local site.
The application was developed and Sql Server WebMatrix Compac 4
If you read the error message it says "Could not load file or assembly 'Microsoft.Web.Helpers' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded." If you then look at the version of the ASP.NET that this site is attempting to run under, it is ASP.NET Version:2.0.50727.4209.
Web Pages and the Web Helpers library need Version 4.0. Make sure the site targets the correct version of ASP.NET.
For missing assemblies a simple solution is to just bundle them with your project.
Go to your project -> references -> find this microsoft web helpers ref -> open the properties panel and set Copy Local to True
Edit: Also try setting assembly binding logging.
I suspect that your web.config is fine and that there is an assembly missing from your deployment.
You probably have to include microsoft.web.helpers in your deployment package or simply copy it to the bin folder.
You might find that there are other assemblies missing but you should be able to pick them off one by one.
There is a previous question Hosting WebMatrix Page
that lists all of the dlls you have to deploy and also suggests using Webdeploy

WCSF Random assembly manifest definition does not match assembly ref in .NET 2.0

I'm running WCSF Feb 2008 along with Enterprise Library 3.1 and noticed that randomly I get the "fun"
Could not load file or assembly Microsoft.Practices.EnterpriseLibrary.Common, Version=3.1.0.0, Culture=neutral, Public ... The located assembly's manifest definition does not match the assembly reference.
Usually this wouldn't be worth mentioning on stackoverflow, but the strange thing is that the first time I fire this up it breaks, but if I close it down and simply hit F11 again - it works .... strange. Does anyone know why this might break sometimes, but not others?
The problem was related to my version of the data access DLL I was adding. I found that if I went to the following:
C:\Program Files\Microsoft Web Client
Software Factory February
2008\Microsoft Practices Library
and imported this specific data access DLL instead of the one I compiled myself from the Enterprise Library 3.1 installer, everything worked great.