Method not found: 'Void System.Web.UI.ScriptResourceDefinition - vb.net

I've built a fairly simple website in using Visual Studio 2012 using .net 4.5 version.
When I uploaded the website to my server I get the following error:
Method not found: 'Void System.Web.UI.ScriptResourceDefinition.set_LoadSuccessExpression(System.String)'.
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.MissingMethodException: Method not found: 'Void System.Web.UI.ScriptResourceDefinition.set_LoadSuccessExpression(System.String)'.
[MissingMethodException: Method not found: 'Void System.Web.UI.ScriptResourceDefinition.set_LoadSuccessExpression(System.String)'.]
Microsoft.ScriptManager.WebFormsv45.PreApplicationStartCode.Start() +0
[InvalidOperationException: The pre-application start initialization method Start on type Microsoft.ScriptManager.WebFormsv45.PreApplicationStartCode threw an exception with the following error message: Method not found: 'Void System.Web.UI.ScriptResourceDefinition.set_LoadSuccessExpression(System.String)'..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +423
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +677
[HttpException (0x80004005): The pre-application start initialization method Start on type Microsoft.ScriptManager.WebFormsv45.PreApplicationStartCode threw an exception with the following error message: Method not found: 'Void System.Web.UI.ScriptResourceDefinition.set_LoadSuccessExpression(System.String)'..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090876
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256
(the hosting company provides the following: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272)
I am aware of this question/answer:
http://forums.asp.net/t/1823969.aspx/1 But I find it wasn't very helpful since it doesn't provide any details about where I would correct the references (I am not sure where/what csproj is).
Also I am aware of the similar question posted here with no answers:
Method not found: 'Void System.Web.UI.ScriptResourceDefinition.set_LoadSuccessExpression(System.String)'
Any tips and suggestions how to fix this issue are appreciated.
Thank you!

The LoadSuccessExpression property is a new property in .NET 4.5. Since your host only supports .NET 4, this property does not exist when deployed.
You're getting a missing method exception since a property setter is really just a method behind the scenes.

Related

Is it possible in ASP.NET Core to enable XmlSerialization for a single controller

I have a Web API that has several controllers, one of which returns XML for legacy reasons, while all the others return JSON.
In a .NET Framework I can selectively enable XML serialization for a single controller by accessing HttpControllerSettings.Formatters (typically in an attribute used to decorate the controller).
Is it possible to do the same in ASP.NET Core, i.e. only enable Xml serialization for a single controller?
The only way I've found to enable Xml serialization in ASP.NET Core 2.1 is globally, using:
services.AddMvc()
.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
.AddXmlSerializerFormatters();
This works OK, but has a side-effect that I consider to be undesirable: when I run the application in Visual Studio I see a trace of an warning from XmlSerializerOutputFormatter something like:
Microsoft.AspNetCore.Mvc.Formatters.XmlSerializerOutputFormatter:Warning: An error occurred while trying to create an XmlSerializer for the type 'MyApp.MyModel'.
System.InvalidOperationException: There was an error reflecting type 'MyApp.MyModel'. ---> System.InvalidOperationException: Cannot serialize member ... see inner exception for more details. ---> System.NotSupportedException: Cannot serialize ... because it is an interface.
--- End of inner exception stack trace ---
at System.Xml.Serialization.StructModel.CheckSupportedMember(TypeDesc typeDesc, MemberInfo member, Type type)
...
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
at Microsoft.AspNetCore.Mvc.Formatters.XmlSerializerOutputFormatter.CreateSerializer(Type type)
It appears to be trying to create an XmlSerializer for a Type that is not used by my "XML" controller.
While it's not a showstopper, I'd prefer not to be creating XmlSerializers except when I need them.
I've encountered the same issue. I do not believe there is a solution at the moment, so I've created a feature request on the Github project.
In the meantime, I've set
"Logging": {
"LogLevel": {
"Microsoft.AspNetCore.Mvc.Formatters.XmlSerializerOutputFormatter": "Error"
}
}
To suppress the warnings during startup.
I've encountered the same issue.Then I changed my code:
builder.Services.AddControllers().AddNewtonsoftJson().AddXmlSerializerFormatters();
U can check this one out, I hope it's has been helpful.

How to fix 'System.ServiceModel.Channels.ReceivedFault' cannot be serialized

I have a workflow service. I also use workflow persistence in that service. But after I deployed workflow in IIS, from client I make a request to workflow service, in log file on server. I see a message
The execution of the InstancePersistenceCommand named {urn:schemas-microsoft-com:System.Activities.Persistence/command}SaveWorkflow was interrupted by an error.InnerException Message: Type 'System.ServiceModel.Channels.ReceivedFault' cannot be serialized.
Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.
If the type is a collection, consider marking it with the CollectionDataContractAttribute. See the Microsoft .NET Framework documentation for other supported types.
I tried research about this exception, but I didn't find anything.
How to fix this problem ? or let me know what is the reason about above exception ?
System.ServiceModel.Channels.ReceivedFault is a non-serializable internal .NET framework class, so unfortunately there is nothing you can do to correct the actual root cause (i.e. making said class serializable).
You are probably calling an external service via WCF which faults, i.e. a System.ServiceModel.FaultException is thrown. IIRC, somewhere deep down in that FaultException object is a reference to the culprit, a ReceivedFault instance.
Solution: Catch all FaultExceptions, transfer the information you need to know from the FaultException into a serializable exception, and throw the latter:
try
{
CallService();
}
catch (FaultException ex)
{
// Gather all info you need from the FaultException
// and transport it in a serializable exception type.
// I'm just using Exception and the message as an example.
throw new Exception(ex.Message);
}

How to hide Fault error description(WCF and Silverlight)

I have silverlight application which uses WCF for database operations. Using Fiddler I am able to tamper the parameters required for a particular method used in WCF and getting an exception "a:DeserializationFailedThe formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:parameters. The InnerException message was 'There was an error deserializing the object of type........". My security team does not like this and saying it is exposing the real exception. Is there any way to handle this type of exception and show some user define message? If yes then please provide the complete sample. I went through so many articles in internet but none of them is having complete solution.
You need to implement a custom error handler. See
http://msdn.microsoft.com/en-us/library/ms599828
For lots of reference details and this
http://www.neovolve.com/post/2008/04/07/implementing-ierrorhandler.aspx
For an example that implements (in a basic, but instructive way) exactly the exception shielding behaviour you are looking for.

Problem with spring + nhibernate in .net environment

I am working with Spring.net 1.3 and nHibernate for .net 1.3.
While fetching the application context using XML ( _appContext = new XmlApplicationContext("abc.xml")) I am getting the exception as
"Error creating object with name 'NHibernateSessionFactory' defined in abc.xml"
Initialization of object failed : The following types may not be used as proxies"
I have declared all the properties of class as public virtual.still why am i getting this exception
Thanks in advance
You must have missed marking a property or method virtual. The exception (or an InnerException, I'm not familiar with Spring) message should tell you exactly which type is the problem. For example, I just reproduced this:
{"The following types may not be used as proxies:\nModel.Project: method get_ProjectId should be 'public/protected virtual' or 'protected internal virtual'"}

System.ServiceModel.Security.MessageSecurityException occuring under ExceptionShielding

We are using the Enterprise Library 4.1 Exception Handling Application Block's ExceptionShielding feature in combination with a custom RoleProvider with our WCF services.
When the RoleProvider determines an user is not in a role and returns false from the IsInRole method, the following exception is occurring:
System.ServiceModel.Security.MessageSecurityException, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
No signature message parts were specified for messages with the '{XXX}' action.
WCF then aborts the RequestContext of the service operation, and the client times out.
I have attempted the solution referred to at this link with no success:
http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=25236
We also removed the System.Exception exception type from the EHAB policy, effectively having EHAB doing nothing for this policy, and this has no effect.
The only thing that prevents this exception is commenting out the ExceptionShielding attribute on the service implementation.
Any fix for this issue would be much appreciated.
I spent hours and hours trying to find out the reason.
I have posted my answer here.
Basically you need to define the Fault Action and set it to the same namespace.