I have a problem with deserialization of an object:
byte[] cardData;
// Serialize
var mySerializer1 = new BinaryFormatter();
using (var ms = new MemoryStream())
{
mySerializer1.Serialize(ms, new SuperClass());
cardData = ms.ToArray();
}
// Deserialize
var mySerializer2 = new BinaryFormatter();
using (var ms = new MemoryStream(cardData))
mySerializer2.Deserialize(ms); // throws an exception
In the same file:
[Serializable]
public class SuperClass
{ }
Exception:
System.Runtime.Serialization.SerializationException: Unable to find assembly "SKM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null".
в System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
в System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
в System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
в System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
в System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
в System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
в System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
в System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
в System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
в SKM.InputFiles.InputFileMsr.GetRecords() в c:\Stas\Projects\CardMaster\Current\MACS\Application\BankProcessors\SKM\InputFiles\InputFileMsr.cs:строка 204
The SKM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null is the assembly in which I run all this code. Why does CLR cannot find it?
I tested this code in a separate application and it all works fine. But in my application throws an exception. Maybe this is because of AppDomain in which i load this dll? How to fix it?
UPDATE 2: Add Fusion logs.
SKM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null:
*** Assembly Binder Log Entry (28.05.2015 # 17:05:51) ***
The operation failed.
Bind result: hr = 0x80070002. Не удается найти указанный файл.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = SKM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
*** Assembly Binder Log Entry (28.05.2015 # 17:05:51) ***
The operation failed.
Bind result: hr = 0x80070002. Не удается найти указанный файл.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = SKM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
SKM:
*** Assembly Binder Log Entry (28.05.2015 # 17:05:51) ***
The operation failed.
Bind result: hr = 0x80070002. Не удается найти указанный файл.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = SKM
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: SKM | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM.DLL.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM/SKM.DLL.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM.EXE.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM/SKM.EXE.
LOG: All probing URLs attempted and failed.
*** Assembly Binder Log Entry (28.05.2015 # 17:05:51) ***
The operation failed.
Bind result: hr = 0x80070002. Не удается найти указанный файл.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = SKM
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: SKM | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM.DLL.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM/SKM.DLL.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM.EXE.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM/SKM.EXE.
LOG: All probing URLs attempted and failed.
Related
I add the file to the directory but it is still telling me that it cannot find the file. What am I suppose to do now to fix this error?
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'CrystalDecisions.Web, Version=13.0.32.4286, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 18:
Line 19:
Line 20:
Line 21:
Line 22:
Source File: C:\inetpub\wwwroot\POS\web.config Line: 20
Assembly Load Trace: The following information can be helpful to determine why the assembly 'CrystalDecisions.Web, Version=13.0.32.4286, Culture=neutral, PublicKeyToken=692fbea5521e1304' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = CrystalDecisions.Web, Version=13.0.32.4286, Culture=neutral, PublicKeyToken=692fbea5521e1304
(Fully-specified)
LOG: Appbase = file:///C:/inetpub/wwwroot/POS/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\POS\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\POS\web.config
LOG: Using host configuration file: C:\Users\okdok\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: CrystalDecisions.Web, Version=13.0.32.4286, Culture=neutral, PublicKeyToken=692fbea5521e1304
LOG: Attempting download of new URL file:///C:/Users/okdok/AppData/Local/Temp/Temporary ASP.NET Files/vs/28ae311b/78674aee/CrystalDecisions.Web.DLL.
LOG: Attempting download of new URL file:///C:/Users/okdok/AppData/Local/Temp/Temporary ASP.NET Files/vs/28ae311b/78674aee/CrystalDecisions.Web/CrystalDecisions.Web.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/POS/bin/CrystalDecisions.Web.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
<assemblies>
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportAppServer.Controllers, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportAppServer.DataDefModel, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304" />
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
Also do you know what I should do about this error:
Could not load file or assembly 'Microsoft.ReportingServices.Interfaces' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'Microsoft.ReportingServices.Interfaces' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.ReportingServices.Interfaces' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = Microsoft.ReportingServices.Interfaces
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.ReportingServices.Interfaces | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/inetpub/wwwroot/POS/
LOG: Initial PrivatePath = C:\inetpub\wwwroot\POS\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\inetpub\wwwroot\POS\web.config
LOG: Using host configuration file: C:\Users\okdok\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/okdok/AppData/Local/Temp/Temporary ASP.NET Files/vs/28ae311b/78674aee/Microsoft.ReportingServices.Interfaces.DLL.
LOG: Attempting download of new URL file:///C:/Users/okdok/AppData/Local/Temp/Temporary ASP.NET Files/vs/28ae311b/78674aee/Microsoft.ReportingServices.Interfaces/Microsoft.ReportingServices.Interfaces.DLL.
LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/POS/bin/Microsoft.ReportingServices.Interfaces.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'Microsoft.ReportingServices.Interfaces' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +232
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +113
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +23
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +49
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.ReportingServices.Interfaces' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +762
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +259
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +167
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +238
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +78
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +334
System.Web.Compilation.BuildManager.ExecutePreAppStart() +178
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +746
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.ReportingServices.Interfaces' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +552
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +122
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +737
I have read the following article http://msdn.microsoft.com/en-us/library/ff650307.aspx, about how i can authenticate asp.net mvc users from multiple domains, so inside my asp.net mvc i did the following :-
I added the following to my web.config:-
<system.web>
<membership>
<providers>
<add name="TestDomain1ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="TestDomain1ConnectionString" connectionUsername="ad-domainA.intra\it360ad.user" connectionPassword="$$$$$" />
</providers>
</membership>
&
<connectionStrings>
<add name="TestDomain1ConnectionString" connectionString="LDAP://ad-domainA.intra/CN=Users,DC=ad-domainA,DC=intra" />
and i added the following Account.controller:-
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
ViewBag.ReturnUrl = returnUrl;
return View();
}
//
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
MembershipProvider domainProvider;
domainProvider = Membership.Providers["TestDomain1ADMembershipProvider"];
// Validate the user with the membership system.
if (domainProvider.ValidateUser(model.UserName, model.Password))
{
if (Request.QueryString["ReturnUrl"] != null)
{
FormsAuthentication.RedirectFromLoginPage(
model.UserName, false);
}
else
{
// If there is no RequestUrl query string attribute, just set
// the authentication cookie. Provide navigation on the login page
// to pages that require authentication, or user can use browser
// to navigate to protected pages.
// Set second parameter to false so cookie is not persistent
// across sessions.
FormsAuthentication.SetAuthCookie(model.UserName, false);
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
}
return RedirectToLocal(returnUrl);
}
but when i type my user name and password inside the login screen and click on enter , i got the following error:-
System.Configuration.ConfigurationErrorsException was unhandled by
user code HResult=-2146232062 Message=Could not load file or
assembly 'System.Web, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.
(C:\Users\john.john\Desktop\test login\TMS\TMS\web.config line 39)
Source=System.Web BareMessage=Could not load file or assembly
'System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one
of its dependencies. The system cannot find the file specified.
Filename=C:\Users\john.john\Desktop\test login\TMS\TMS\web.config
Line=39 StackTrace:
at System.Web.Security.Membership.Initialize()
at System.Web.Security.Membership.get_Providers() InnerException: System.IO.FileNotFoundException
HResult=-2147024894
Message=Could not load file or assembly 'System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified.
Source=mscorlib
FileName=System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
FusionLog==== Pre-bind state information === LOG: User = AD-ITSERVICES\john.john LOG: DisplayName = System.Web,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Partial) WRN:
Partial binding information was supplied for an assembly: WRN:
Assembly Name: System.Web, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a | Domain ID: 4 WRN: A partial bind
occurs when only part of the assembly display name is provided. WRN:
This might result in the binder loading an incorrect assembly. WRN: It
is recommended to provide a fully specified textual identity for the
assembly, WRN: that consists of the simple name, version, culture, and
public key token. WRN: See whitepaper
http://go.microsoft.com/fwlink/?LinkId=109270 for more information and
common solutions to this issue. LOG: Appbase =
file:///C:/Users/john.john/Desktop/test login/TMS/TMS/ LOG: Initial
PrivatePath = C:\Users\john.john\Desktop\test login\TMS\TMS\bin
Calling assembly : (Unknown).
=== LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\john.john\Desktop\test
login\TMS\TMS\web.config LOG: Using host configuration file:
C:\Users\john.john\Documents\IISExpress\config\aspnet.config LOG:
Using machine configuration file from
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private,
custom, partial, or location-based assembly bind). LOG: Attempting
download of new URL
file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary ASP.NET
Files/root/2fc69b03/2c0137b8/System.Web.DLL. LOG: Attempting download
of new URL file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary
ASP.NET Files/root/2fc69b03/2c0137b8/System.Web/System.Web.DLL. LOG:
Attempting download of new URL file:///C:/Users/john.john/Desktop/test
login/TMS/TMS/bin/System.Web.DLL. LOG: Attempting download of new URL
file:///C:/Users/john.john/Desktop/test
login/TMS/TMS/bin/System.Web/System.Web.DLL. LOG: Attempting download
of new URL file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary
ASP.NET Files/root/2fc69b03/2c0137b8/System.Web.EXE. LOG: Attempting
download of new URL
file:///C:/Users/john.john/AppData/Local/Temp/2/Temporary ASP.NET
Files/root/2fc69b03/2c0137b8/System.Web/System.Web.EXE. LOG:
Attempting download of new URL file:///C:/Users/john.john/Desktop/test
login/TMS/TMS/bin/System.Web.EXE. LOG: Attempting download of new URL
file:///C:/Users/john.john/Desktop/test
login/TMS/TMS/bin/System.Web/System.Web.EXE.
StackTrace:
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean
loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly,
StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement,
XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase)
InnerException:
on the following line of code inside the Account controller:-
public ActionResult Login(LoginModel model, string returnUrl)
{MembershipProvider domainProvider;
domainProvider = Membership.Providers["TestDomain1ADMembershipProvider"];
so what is causing this error?
For this declaration of System.Web
System.Web, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
The version is also needed (4.0 right?)
Version=4.0.0.0
I'm trying to use CreateApplicationHost to render the content of an ASP webpage. The exact code is as follows:
public class LocalPageContentAppropriator {
private RemoteDomain _host;
protected RemoteDomain Host {
get {
if (_host == null) {
_host = (RemoteDomain)ApplicationHost.CreateApplicationHost(typeof(RemoteDomain), "/", SettingsFactory.Instance.WebFileRoot + "\\");
}
return _host;
}
}
public string Resolve(string page, string query) {
return Host.ProcessRequest(page, query);
}
}
public class RemoteDomain : MarshalByRefObject {
public string ProcessRequest(string page, string query) {
using (StringWriter sw = new StringWriter()) {
SimpleWorkerRequest work = new SimpleWorkerRequest(page, query, sw);
HttpRuntime.ProcessRequest(work);
return sw.ToString();
}
}
}
The path returned for SettingsFactory.Instance.WebFileRoot points to the website's physical directory. Have tried putting appending "\bin\", etc but regardless of what I try I still receive the same error, even if I intentionally enter an incorrect path.
Now, here's where it gets interesting. Fusion Logging usually returns something like this when the assembly is loaded correctly (under normal use):
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable c:\windows\microsoft.net\framework\v4.0.30319\aspnet_wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = WICKEDWE-FFB297\ASPNET
LOG: DisplayName = MyWebsite.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Projects/Clients/G/MyWebsite/Development/MasterSite/trunk/MyWebsite.Web.Site/
LOG: Initial PrivatePath = C:\Projects\Clients\G\Galderma\Emervel\Development\MasterSite\trunk\MyWebsite.Web.Site\bin
LOG: Dynamic Base = C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\3610448a\a3b3a5e7
LOG: Cache Base = NULL
LOG: AppName = Umbraco_Sandbox_98a12b84-6e7b-401f-a543-87e17c021ad5
Calling assembly : MyWebsite.Web.Site, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Projects\Clients\G\Galderma\Emervel\Development\MasterSite\trunk\MyWebsite.Web.Site\web.config
LOG: Using host configuration file: c:\windows\microsoft.net\framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Binding succeeds. Returns assembly from C:\Projects\Clients\G\Galderma\Emervel\Development\MasterSite\trunk\MyWebsite.Web.Site\bin\MyWebsite.Web.dll.
LOG: Assembly is loaded in default load context.
However, the error shows a different (IMO incorrect) Appbase path:
2011-02-08 11:10:03,734 [T1] ERROR MyWebsite.Web.Site.Common.Controls.Forms.Register [L91] - Member registration.
System.IO.FileNotFoundException: Could not load file or assembly 'MyWebsite.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'MyWebsite.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.UnitySerializationHolder.GetRealObject(StreamingContext context)
at System.Web.Hosting.ApplicationManager.CreateInstanceInNewWorkerAppDomain(Type type, String appId, VirtualPath virtualPath, String physicalPath)
at System.Web.Hosting.ApplicationHost.CreateApplicationHost(Type hostType, String virtualDir, String physicalDir)
at MyWebsite.Web.LocalPageContentAppropriator.get_Host() in C:\Projects\Clients\G\MyWebsite\Development\MasterSite\trunk\MyWebsite.Web\LocalPageContentAppropriator.cs:line 17
at MyWebsite.Web.LocalPageContentAppropriator.Resolve(String page, String query) in C:\Projects\Clients\G\MyWebsite\Development\MasterSite\trunk\MyWebsite.Web\LocalPageContentAppropriator.cs:line 24
at MyWebsite.Model.ProfessionalMemberLogic.Create(IProfessionalMemberInput input, String completedPagePath, String activationEmailPath, String contextPath) in C:\Projects\Clients\G\MyWebsite\Development\MasterSite\trunk\MyWebsite\Model\ProfessionalMemberLogic.cs:line 66
at MyWebsite.Web.Site.Common.Controls.Forms.Register.btnRegister_Click(Object sender, EventArgs e) in C:\Projects\Clients\G\MyWebsite\Development\MasterSite\trunk\MyWebsite.Web.Site\Common\Controls\Forms\Register.ascx.cs:line 84
Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable c:\windows\microsoft.net\framework\v4.0.30319\aspnet_wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = WICKEDWE-FFB297\ASPNET
LOG: DisplayName = MyWebsite.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///c:/windows/microsoft.net/framework/v4.0.30319/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: c:\windows\microsoft.net\framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///c:/windows/microsoft.net/framework/v4.0.30319/MyWebsite.Web.DLL.
LOG: Attempting download of new URL file:///c:/windows/microsoft.net/framework/v4.0.30319/MyWebsite.Web/MyWebsite.Web.DLL.
LOG: Attempting download of new URL file:///c:/windows/microsoft.net/framework/v4.0.30319/MyWebsite.Web.EXE.
LOG: Attempting download of new URL file:///c:/windows/microsoft.net/framework/v4.0.30319/MyWebsite.Web/MyWebsite.Web.EXE.
Any ideas guys?
I don't now if you get your answer or not, but I'm trying exactly the same thing and had exactly the same problems.
One, and most simple, is to put your assembly inside GAC.
Two, and a little bit tricky, is to copy your assembly to the 'bin' directory inside the directory 'physicalDir' used as parameter to ApplicationHost.CreateApplicationHost method.
It is well explained here: http://www.west-wind.com/Weblog/posts/2613.aspx
The implementation of ApplicationHost.CreateApplicationHost expects to find the assembly of the specified type in one of two places: either in the Global Assembly Cache (GAC) or within the bin directory under the specified physical directory. There is no documented way to change this behavior short of reimplementing CreateApplicationHost. So depending on your project configuration and deployment scenario, you may need to install the assembly into one of these locations.
Please take a look here for more details.
Idealty, your host will be in different assembly (that you deploy under "bin" of your physical server dir).
We have a simple task that, before compiling, makes all of our AssemblyInfo.cs files editable, then updates
[assembly: AssemblyVersion("1.0.0.0")]
to
[assembly: AssemblyVersion("1.0.0.<SourceGetVersion>")]
All of our assemblies are signed using the same key.
This kind of thing is probably fairly standard, and it works just fine, except that it causes test failures.
The failures look like this:
Test method
Namespace.Tests.MessageTest.TestMethod
threw exception:
System.IO.FileLoadException: Could not
load file or assembly
'Namespace.BusinessLayer.BusinessComponent.Documents,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx' or
one of its dependencies. The located
assembly's manifest definition does
not match the assembly reference.
(Exception from HRESULT: 0x80131040)
So, I turned on the logging that was suggested, and get this:
W, 3964, 90, 2010/12/07, 09:57:43.059,
TFSBUILD\QTAgent32.exe, Getting
custom attributes for type
System.Reflection.RuntimeMethodInfo
threw exception (will ignore and use
the reflection way):
System.IO.FileLoadException: Could not
load file or assembly
'Namespace.BusinessLayer.BusinessEntity,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx' or
one of its dependencies. The located
assembly's manifest definition does
not match the assembly reference.
(Exception from HRESULT: 0x80131040)
File name:
'Namespace.BusinessLayer.BusinessEntity,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx' at
System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule
pModule, IRuntimeMethodInfo pCtor,
Byte** ppBlob, Byte* pEndBlob, Int32*
pcNamedArgs) at
System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule
module, IRuntimeMethodInfo ctor,
IntPtr& blob, IntPtr blobEnd, Int32&
namedArgs) at
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule
decoratedModule, Int32
decoratedMetadataToken, Int32
pcaCount, RuntimeType
attributeFilterType, Boolean
mustBeInheritable, IList
derivedAttributes, Boolean
isDecoratedTargetSecurityTransparent)
at
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo
method, RuntimeType caType, Boolean
inherit) at
System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Boolean
inherit) at
Microsoft.VisualStudio.TestTools.Common.ReflectHelper.GetAttributes(MemberInfo
info, Boolean bInherit)
=== Pre-bind state information === LOG: User = domain\tfsbuildAccount
LOG: DisplayName =
Namespace.BusinessLayer.BusinessEntity,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx
(Fully-specified) LOG: Appbase =
file:///D:/Builds/4/10/TestResults/tfsbuildAccount-TFSBUILD
2010-12-07 09_56_54_x86_Debug/Out LOG:
Initial PrivatePath = NULL Calling
assembly :
Namespace.BusinessLayer.BusinessComponent.Edi.Tests,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx.
=== LOG: This bind starts in default load context. LOG: Using application
configuration file:
D:\Builds\4\10\TestResults\tfsbuildAccount-TFSBUILD
2010-12-07
09_56_54_x86_Debug\Out\Namespace.BusinessLayer.BusinessComponent.Edi.Tests.DLL.config
LOG: Using host configuration file:
LOG: Using machine configuration file
from
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference:
Namespace.BusinessLayer.BusinessEntity,
Version=1.0.0.4344, Culture=neutral,
PublicKeyToken=xxxxxxxxxxxxxxxx LOG:
Attempting download of new URL
file:///D:/Builds/4/10/TestResults/tfsbuildAccount-TFSBUILD
2010-12-07
09_56_54_x86_Debug/Out/Namespace.BusinessLayer.BusinessEntity.DLL.
WRN: Comparing the assembly name
resulted in the mismatch: Revision
Number ERR: Failed to complete setup
of assembly (hr = 0x80131040). Probing
terminated.
Now, I may have mixed up the assemblies posting this, but it's the same pattern for all the tests. Mind you, the public keys are all the same, and I can see that all of the revision numbers are the same.
What are we doing wrong?
Try changing the reference assebly to be not version specific. "Secific Version = False" in the properties tab for the assembly.
So I copied the sample code from the Moq home page pretty much verbatim, and am getting a castle proxy exception.
Here's my code (as a console app for an easier sample)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Moq;
namespace MoqTestConsole
{
public interface ILoveThisFramework
{
bool DownloadExists(string s);
}
class Program
{
static void Main(string[] args)
{
Mock<ILoveThisFramework> mock = new Mock<ILoveThisFramework>();
// WOW! No record/replay weirdness?! :)
mock.Setup(framework => framework.DownloadExists("2.0.0.0")).Returns(true);
// Hand mock.Object as a collaborator and exercise it,
// like calling methods on it...
ILoveThisFramework lovable = mock.Object;
bool download = lovable.DownloadExists("2.0.0.0");
// Verify that the given method was indeed called with the expected value
mock.Verify(framework => framework.DownloadExists("2.0.0.0"));
}
}
}
Everything compiles nicely, but when it calls mock.Object The following exception is thrown.
System.TypeInitializationException was unhandled
Message=The type initializer for 'Moq.Mock`1' threw an exception.
Source=Moq
TypeName=Moq.Mock`1
StackTrace:
at Moq.Mock`1.<InitializeInstance>b__0() in d:\Code\moq\src\Source\Mock.Generic.cs:line 138
at Moq.PexProtector.Invoke(Action action) in d:\Code\moq\src\Source\PexProtector.cs:line 56
at Moq.Mock`1.InitializeInstance() in d:\Code\moq\src\Source\Mock.Generic.cs:line 136
at Moq.Mock`1.OnGetObject() in d:\Code\moq\src\Source\Mock.Generic.cs:line 153
at Moq.Mock.GetObject() in d:\Code\moq\src\Source\Mock.cs:line 152
at Moq.Mock.get_Object() in d:\Code\moq\src\Source\Mock.cs:line 147
at Moq.Mock`1.get_Object() in d:\Code\moq\src\Source\Mock.Generic.cs:line 131
at MoqTestConsole.Program.Main(String[] args) in C:\Projects\Test\MoqTestConsole\MoqTestConsole\Program.cs:line 25
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.TypeInitializationException
Message=The type initializer for 'Moq.Proxy.CastleProxyFactory' threw an exception.
Source=Moq
TypeName=Moq.Proxy.CastleProxyFactory
StackTrace:
at Moq.Proxy.CastleProxyFactory..ctor()
at Moq.Mock`1..cctor() in d:\Code\moq\src\Source\Mock.Generic.cs:line 54
InnerException: System.IO.FileNotFoundException
Message=Could not load file or assembly 'Castle.Core, Version=2.5.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The system cannot find the file specified.
Source=Moq
FileName=Castle.Core, Version=2.5.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
FusionLog==== Pre-bind state information ===
LOG: User = jsi-dev-001\jmacintyre
LOG: DisplayName = Castle.Core, Version=2.5.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
(Fully-specified)
LOG: Appbase = file:///C:/Projects/Test/MoqTestConsole/MoqTestConsole/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Castle.Core, Version=2.5.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc
LOG: Attempting download of new URL file:///C:/Projects/Test/MoqTestConsole/MoqTestConsole/bin/Debug/Castle.Core.DLL.
LOG: Attempting download of new URL file:///C:/Projects/Test/MoqTestConsole/MoqTestConsole/bin/Debug/Castle.Core/Castle.Core.DLL.
LOG: Attempting download of new URL file:///C:/Projects/Test/MoqTestConsole/MoqTestConsole/bin/Debug/Castle.Core.EXE.
LOG: Attempting download of new URL file:///C:/Projects/Test/MoqTestConsole/MoqTestConsole/bin/Debug/Castle.Core/Castle.Core.EXE.
StackTrace:
at Moq.Proxy.CastleProxyFactory..cctor()
InnerException:
So it appears to be a Castle Proxy component that's missing, but I'm referencing the binary from the NET40-NoCastle directory.
Latest version of Moq (Moq.4.0.10827)
And I'm new to Moq, so I may be doing something extremely dense.
It turns out the problem was that I was using the NET40-NoCastle binaries, which apparently means you are using Castle Windsor and already have the Castle Windsor binaries in your project. I had the misassumption this directory was for projects that don't use Castle Windsor.
Anyway, bottom line, if you're have this same issue, use the binaries from the NET40 directories instead.
Thanks Ben Alabaster for the answer via Twitter.