Azure VM MVC website unity - azure

I have a MVC website, which using Dependency Injection "Unity", it is running fine on my local machine and also no problem on my old dedicated server (Window SEVER 2008 R2 SP1). When I move the website to Azure VM (Window SEVER 2008 R2 SP1), I got following error message;
Server Error in '/' Application.
The IControllerFactory 'Store.Factories.UnityControllerFactory' did not return a controller for the name 'Home'.
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.InvalidOperationException: The IControllerFactory 'Store.Factories.UnityControllerFactory' did not return a controller for the name 'Home'.
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.
Stack Trace:
[InvalidOperationException: The IControllerFactory 'Store.Factories.UnityControllerFactory' did not return a controller for the name 'Home'.]
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +423
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +73
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +921
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0
I cannot figure out why, Any help?

The problem was solved automatically by upgrading Unity from 2 to 4.

Related

Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)

We have SharePoint 2013 Servers that were patched with windows updates and since then we are receiving the following error. We have restarted the servers, removed the windows updates manually and then restarted the servers, restored to a copy of windows server before the windows update but the error is persisting. We have also removed the temporary files from Windows directory and nothing is helping.
I have attached a screenshot of the Windows Updates that were applied to our servers overnight
Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
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.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
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.
Stack Trace:
[FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)]
System.Linq.Enumerable.Any(IEnumerable`1 source) +0
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromAssemblyCollection(IEnumerable`1 assemblies, Boolean buildingFromCache) +210
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +98
System.Web.Compilation.BuildManager.ExecutePreAppStart() +139
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1005
[HttpException (0x80004005): Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +646
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +779
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.36366
I ran into the same exception when developing on Sitecore, and an iisreset cleared the issue.
The solution appears to be:
Create a new registry DWORD value called LoaderOptimization and give it the value 1 within the key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework”.
Further reading:
http://blog.bugrapostaci.com/2017/02/08/loading-this-assembly-would-produce-a-different-grant-set-from-other-instances-exception-from-hresult-0x80131401/
https://social.technet.microsoft.com/Forums/en-US/5db05238-3c12-4e7e-af95-ca56545f0721/loading-this-assembly-would-produce-a-different-grant-set-from-other-instances?forum=sharepointgeneral
I was able to solve this issue by going into Bindings -> Edit, then removing "localhost" as the Host Name of the site. Worked after that.
Try disable "Remote Desktop" if it is enabled
(example)
After running the command isreset and changing registry,my problem solved.
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0

NullReferenceException at ServerRequestSecurityState.GetSecurityGroupsForCurrentUser(IWindowsIdentity identity)

I have deployed one Lightswitch application. Details are:
Used VS2013
Have HTML Client for application
Have desktop client deployed in web for role/users/permission management
Used windows authentication and allow access to only those mentioned in aspnet provider database(desktop client)
IIS7.5
I am getting some error when I access the page, it give be below error.
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
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.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.LightSwitch.Utilities.Server.Internal.ServerRequestSecurityState.GetSecurityGroupsForCurrentUser(IWindowsIdentity identity) +56
Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsWindowsUserRegistered(IPrincipal principal, ServerRequestSecurityState state) +373
Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsUserRegistered(IPrincipal principal) +317
Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.AuthenticateRequest(HttpContextBase context, HttpStatusCode& status, Exception& authException) +201
Microsoft.LightSwitch.WebHost.Implementation.LightSwitchHttpModule.HandlePostAuthenticateRequest() +201
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +79
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +164
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446
Following is the warning logged in event log.
+ System
- Provider
[ Name] ASP.NET 4.0.30319.0
- EventID 1309
[ Qualifiers] 32768
Level 3
Task 3
Keywords 0x80000000000000
- TimeCreated
[ SystemTime] 2014-08-01T15:03:43.000000000Z
EventRecordID 107901
Channel Application
Computer <DELETED>
Security
- EventData
3005
An unhandled exception has occurred.
8/1/2014 8:33:43 PM
8/1/2014 3:03:43 PM
e6e596e599ff4465968b9afeb7739958
183
58
0
/LM/W3SVC/8/ROOT-1-130513779129486922
Full
/
D:\PublishedWebsites\CustomerComplaints\
<DELEED>
8976
w3wp.exe
IIS APPPOOL\CustomerComplaints
NullReferenceException
Object reference not set to an instance of an object. at Microsoft.LightSwitch.Utilities.Server.Internal.ServerRequestSecurityState.GetSecurityGroupsForCurrentUser(IWindowsIdentity identity) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsWindowsUserRegistered(IPrincipal principal, ServerRequestSecurityState state) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsUserRegistered(IPrincipal principal) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.AuthenticateRequest(HttpContextBase context, HttpStatusCode& status, Exception& authException) at Microsoft.LightSwitch.WebHost.Implementation.LightSwitchHttpModule.HandlePostAuthenticateRequest() at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
http://<CurrentMachine>:8451/CustomerComplaints/
/CustomerComplaints/
::1
False
IIS APPPOOL\CustomerComplaints
34
IIS APPPOOL\CustomerComplaints
False
at Microsoft.LightSwitch.Utilities.Server.Internal.ServerRequestSecurityState.GetSecurityGroupsForCurrentUser(IWindowsIdentity identity) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsWindowsUserRegistered(IPrincipal principal, ServerRequestSecurityState state) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsUserRegistered(IPrincipal principal) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.AuthenticateRequest(HttpContextBase context, HttpStatusCode& status, Exception& authException) at Microsoft.LightSwitch.WebHost.Implementation.LightSwitchHttpModule.HandlePostAuthenticateRequest() at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I believe it is something wrong with my IIS settings, but not sure. I tried to search cause and solution but not getting any clue.

Error on new build template after migration from TFS2012 to TFS2013

I recently migrated from TFS2012 to a brand new hardware running TFS2013. I was using a slightly customized template to build and deploy my solutions to IIS. They still work ok on TFS2013. Now I want to use the new template "TfvcTemplate.12.xaml" so I setup a new build. When I try to execute it I get this error:
TF215097: An error occurred while initializing a build for build definition \MyProject\Build_Test:
Exception Message: One or more errors occurred. (type AggregateException)
Exception Stack Trace:
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.TeamFoundation.Build.Client.FileContainerHelper.GetFile(TfsTeamProjectCollection projectCollection, String itemPath, Stream outputStream)
at Microsoft.TeamFoundation.Build.Client.FileContainerHelper.GetFileAsString(TfsTeamProjectCollection projectCollection, String itemPath)
at Microsoft.TeamFoundation.Build.Client.ProcessTemplate.Download(String sourceGetVersion)
at Microsoft.TeamFoundation.Build.Hosting.BuildControllerWorkflowManager.PrepareRequestForBuild(WorkflowManagerActivity activity, IBuildDetail build, WorkflowRequest request, IDictionary`2 dataContext)
at Microsoft.TeamFoundation.Build.Hosting.BuildWorkflowManager.TryStartWorkflow(WorkflowRequest request, WorkflowManagerActivity activity, BuildWorkflowInstance& workflowInstance, Exception& error, Boolean& syncLockTaken)
The exception is:
Inner Exception Details:
Exception Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 192.1.1.10:8080 (type SocketException)
Exception Stack Trace:
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
That IP address "192.1.1.10" corresponds to the old server (TFS2012), which is wrong. It seems like there's still some configuration remaining from the migration, pointing to the previous server. Keep in mind the migrated templates build just fine.
Any ideas?
Reinstall the Controller and Re-Select it in the build-Definition
Please Check in Visual Studio under "Build" -->Actions\ManageBuildControllers... that your Controller is available
Ensure that your Controller is set in the "Queue new build"-Action.
You can try to create an empty workflow (With a write to build Message - Activity) to check the connection to your Controller

ACS azure for published application

Hy guys ,
I developed a WebForms application using VS 2012 . I've published it on Azure .
After that I integrated ACS ( i've set the URL to my allready published application)
I published the application again , but it doesn't work .
After I've registered myself (for ex using Yahoo or LiveID) I've got this error :
Server Error in '/' Application.
The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.
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.Security.Cryptography.CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.
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.
Stack Trace:
[CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.]
System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope scope) +379
System.IdentityModel.ProtectedDataCookieTransform.Encode(Byte[] value) +52
[InvalidOperationException: ID1074: A CryptographicException occurred when attempting to encrypt the cookie using the ProtectedData API (see inner exception for details). If you are using IIS 7.5, this could be due to the loadUserProfile setting on the Application Pool being set to false. ]
System.IdentityModel.ProtectedDataCookieTransform.Encode(Byte[] value) +167
System.IdentityModel.Tokens.SessionSecurityTokenHandler.ApplyTransforms(Byte[] cookie, Boolean outbound) +57
System.IdentityModel.Tokens.SessionSecurityTokenHandler.WriteToken(XmlWriter writer, SecurityToken token) +658
System.IdentityModel.Tokens.SessionSecurityTokenHandler.WriteToken(SessionSecurityToken sessionToken) +86
System.IdentityModel.Services.SessionAuthenticationModule.WriteSessionTokenToCookie(SessionSecurityToken sessionToken) +144
System.IdentityModel.Services.SessionAuthenticationModule.AuthenticateSessionSecurityToken(SessionSecurityToken sessionToken, Boolean writeCookie) +82
System.IdentityModel.Services.WSFederationAuthenticationModule.SetPrincipalAndWriteSessionToken(SessionSecurityToken sessionToken, Boolean isSession) +216
System.IdentityModel.Services.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequestBase request) +860
System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args) +369
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
What should i do ?
I've set the URL's correctly. I don't have in web.config any reffernces of "localhost"..
I don't know what I must set additionly for this to work..
By default WIF uses DPAPI to encrypt cookies. Switch to cert based encryption. See this answer:
Is it possible to run WIF without LoadUserProfile = True
Vittorio Bertocci answers the question here
http://www.cloudidentity.com/blog/2013/01/28/running-wif-based-apps-in-windows-azure-web-sites-4/
DPAPI is not available in the cloud web apps and 4.5 has a simple solutions

System.ServiceModel.CommunicationException: Silverlight application reading excel data by excel service

I create a c# console project to read the excel document on the sharepoint server, everything works fine. The problem is when I try to read the excel file data in a silverlight application, a exception popped up as below:
{System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 'http://phc/_vti_bin/excelservice.asmx'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details. ---> System.Security.SecurityException ---> System.Security.SecurityException: Security error.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
--- End of inner exception stack trace ---
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
at CERViewer.ESW.ExcelServiceSoapClient.ExcelServiceSoapClientChannel.EndOpenWorkbook(IAsyncResult result)
at CERViewer.ESW.ExcelServiceSoapClient.CERViewer.ESW.ExcelServiceSoap.EndOpenWorkbook(IAsyncResult result)
at CERViewer.ESW.ExcelServiceSoapClient.EndOpenWorkbook(IAsyncResult result, ObservableCollection`1& status)
at CERViewer.ESW.ExcelServiceSoapClient.OnEndOpenWorkbook(IAsyncResult result)
at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}
The source code:
private void GetFeatures()
{
ExcelServiceSoapClient = new ExcelServiceSoapClient();
string targetWorkbookPath = "http://phc/Shared%20Documents/sample.xlsx";
xlservice.OpenWorkbookCompleted += new EventHandler<OpenWorkbookCompletedEventArgs>(xlservice_OpenWorkbookCompleted);
xlservice.OpenWorkbookAsync(targetWorkbookPath, "en-US", "en-US");
}
void xlservice_OpenWorkbookCompleted(object sender, OpenWorkbookCompletedEventArgs e)
{
sessionId = (string)e.Result; //exception here!!!
}
I tried the ways below, but they all failed.
1: create the file and put it on the "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\isapi\", but it failed again.
2: open the cross-domain workbook and data connection access in the sharepoint server, here
I am totally new to sharepoint and silverlight development, I search around on the net but can't find the answer. anyone could help me???
I fixed the problem by putting the clientaccesspolicy.xml file in the server root.

Resources