Error in using RoleEnvironment to get Configuration - asp.net-mvc-3

my web app is using MVC3 with razor
If I am trying to read anything from ServiceConfig using RoleEnvironment.GetConfigurationSettingValue("senderName")
I am getting error related to Microsoft.IdentityModel
Unable to find assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
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.Runtime.Serialization.SerializationException: Unable to find assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
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:
[SerializationException: Unable to find assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4727747
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725
System.AppDomain.get_Id() +0
<CrtImplementationDetails>.DoCallBackInDefaultDomain(IntPtr function, Void* cookie) +185
<CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* ) +328
<CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* ) +102
[ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.
]
.
It's true that I am making use of Windows identity foundation for Azure acs authentication .But everything worked fine when I deployed to azure.But if I make use of RoleEnvironment to read any settings from my ServiceConfig files (for ex :RoleEnvironment.GetConfigurationSettingValue("Smtpserver")) .Its failing on azure .
But everything workes fine on my local azure appfabric .If I am removing this line of code ,then all workes fine .RoleEnvironment.GetConfigurationSettingValue("Smtpserver"))
I am using two webroles in my cloud app.
Please help me identify the cause of error

How did you installed the WIF on the Azure?
The most reliable way is to have the WIF runtime installed via a startup task. You check out this question here. And I think this one is exact duplicate.

Related

Running an MVC Project on godaddy plesk file io error

I have an MVC web project that I am trying to host on godaddy using plesk for administration. My hosting settings for my web page is httpdocs\WebApplication18\WebApplication18/
I have pointed my web project to my configuration file inside WebApplication18.
Folder access to my files look like this:
Home Directory -> httpdocs -> WebApplication18 -> WebApplication18
-> views -> home -> Index.cshtml
-> web.conf
I am trying to browse to my index.cshtml page. I have set the root to run at WebApplication18 where
my configuration file is stored.
When I type in my hostname inside my address bar I recieve a file IO error that states:
Server Error in '/' Application.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
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:
[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +36
System.Security.CodeAccessPermission.Demand() +48
System.Web.HttpRuntime.get_AppDomainAppPath() +53
System.Web.WebPages.Deployment.PreApplicationStartCode.StartCore() +119
System.Web.WebPages.Deployment.PreApplicationStartCode.Start() +39
To begin with custom error mode was turned on, which I turned off in ASP.Nets
settings. I also commented out the compiler error in the web.conf file, which
reduced the error to a file io error.
The question I had was how can I point to my web page properly in my hosting settings
using mvc so that I can render my index.cshtml page using plesk on a godaddy server?
How am I able to fix this error message? I tried changing all of the permissions
lowered the CAS trust level and it makes no difference to the level of control
I have over my web page.
When I do a File Zilla upload sometimes I receive a certificate, but I just ignore
it and select ok.
This is only permission issue. Please kindly ask your provider to give full permission for you. It will fix your issue.

HTTP Error 500.0 - Internal Server Error, AspNetInitializationExceptionModule VS 2015

After running some NuGet Updates my project will not run locally throwing "HTTP Error 500.0 - Internal Server Error" and referencing Handler "AspNetInitializationExceptionModule"
I'm using VS 2015, .NET Framework 4.6.1, Any CPU, IISExpress.
The refered link suggests I look into the IIS Logs which are full of data but there seems to be no information for these eyes.
I Understand that 500.0 is the server shouting that something generic went wrong but frankly I don't know what to try next.
Any thoughts?
Frustrated in New Hampshire.
More info
adding a vanilla favicon.ico still resulted in 500.0 but now just at the root.
HTTP500: SERVER ERROR - The server encountered an unexpected condition that prevented it from fulfilling the request.
(XHR): GET - http://localhost:3029/
Drilling into Eventviewer/Custom Views/Summary page events I found an ASP.NET 4.0.30319.0 Warning.
At the bottom of the warning detail it says
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) Could not load file or assembly 'Microsoft.AI.Agent.Intercept' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
http://localhost:3029/
So my Nuget Update incorrectly updated Microsoft Application Insights.
Uninstalled it and now I'm back to earning a living.
It seems that when IIS knows it has an exception it should tell the browser.
Pat NH USA

CRM 2015 OnLine - Request for the permission SecurityPermission failed

I'm trying to generate a PDF in memory to send it to a WS. This PDF should be created in memory (Stream) and in the Microsoft CRM "cloud" in a plugin code.
Is this possible?
In the plugin (already coded and deployed) I have this lines, the 3th fails
PdfDocument pdf = new PdfDocument();
PdfPage pdfPage = pdf.AddPage();
XGraphics graphics = XGraphics.FromPdfPage(pdfPage); //<-- ERROR
is this line of code trying to access a resource in the cloud that is not permitted/available?
this is the error:
Unexpected exception from plug-in (Execute): Plugins8.Plugin: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
any ideas?
I assume you are using PDFsharp and you have its libraries merged into your plugin assembly using ILMerge.
If so, the SecurityException can be caused by PDFsharp using GDI+. In partial trusted app domains drawing graphics with GDI+ is not allowed. You can however compile PDFsharp for WPF. Try compiling PDFsharp with directives WPF plus (maybe) SILVERLIGHT.

Validation failed in Entity Framework, ASP.NET MVC3

My application using ASP.NET MVC3 with EF4.1, deployed on IIS7. Recently I've meet an error when trying to save an entity to an existing database on the production server, but everything goes well on my development machine.
I tried to build deploy package in VS2010 and import that package in IIS7, also, I've tried to upload all the solutions and create an application in IIS7 manually, but both of the 2 sites come to an error when executing a function that saves an entity to the database.
Error message is pasted below, but the physical path in error message does not exist in the production server, it's a path in my local development machine. This makes me confused. Has anybody ever seen this before?
BTW, I've fully backed up my database and restored it on the production server, so all the databases are same.
I'm open to hear any advice.
Thanks
Cheng
Error message:
Server Error in '/xxxx' Application. Validation failed for one or
more entities. See 'EntityValidationErrors' property for more details.
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.Data.Entity.Validation.DbEntityValidationException: Validation
failed for one or more entities. See 'EntityValidationErrors' property
for more details.
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:
[DbEntityValidationException: Validation failed for one or more entities. See
'EntityValidationErrors' property for more details.]
System.Data.Entity.DbContext.SaveChanges() +212
xxxxx.Models.SetupRepository.CreateApplicationOption(Guid companyId) in
D:\xxxx\Models\SetupRepository.cs:59
xxxxx.MvcApplication.MvcApplication_PostAcquireRequestState(Object sender, EventArgs e) > in D:\xxxx\Global.asax.cs:87
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously) +75

.net framework data provider error

what is this error(comes up when i test my project)
-->
Unable to find the requested .Net Framework Data Provider. It may not be installed.
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.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
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:
[ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.]
System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName) +1402071
System.Web.UI.WebControls.SqlDataSource.GetDbProviderFactory() +67
System.Web.UI.WebControls.SqlDataSource.GetDbProviderFactorySecure() +22
System.Web.UI.WebControls.SqlDataSource.CreateConnection(String connectionString) +11
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +117
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +21
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +66
System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75
System.Web.UI.Control.EnsureChildControls() +102
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
This is the Configuration
<configuration>
<connectionStrings>
<add name="ConnectionString" connectionString="DataSource=C:\ProgramFiles\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\CIEDB.sdf;Password=sa;Persist Security Info=True"
providerName="Microsoft.SqlServerCe.Client.3.5" />
<add name="ConnectionString2" connectionString="Data Source=C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Samples\Northwind.sdf"
providerName="Microsoft.SqlServerCe.Client.3.5" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
</configuration>
You probably have to set up the correct configuration information (connection strings) in the test project's .config file
Edit: with that config, I did some searching and came across this forum thread:
http://social.msdn.microsoft.com/Forums/en-US/sqlce/thread/ff731bf4-1f50-4f77-955b-e4534474a271/
Where the apparent accepted answer was:
I fix my issue by manually install
SSCEVSTools-Enu.msi from Vs SP1.
There were a few other results on Bing that may be useful as well. Hope it helps
I had this same error when I installed Visual Studio 2010 SP1, then rolled back after I found out it was not so great (major understatement... stay far away from VS2010 SP1). I found online that I could fix this by reinstalling the and I got that file from here. After the reinstall of that software, i started VS 2010 and everything was back to normal. Hope it works for you.
Here is the link I used to get that package:
http://download.microsoft.com/download/0/5/D/05DCCDB5-57E0-4314-A016-874F228A8FAD/SSCEVSTools-ENU.msi
From your description, I assume the connection string is invalid. One easy way to create a working connection string is the following:
Create a new, empty text file on the desktop
Change its file extenstion to .udl
Double click on it. This opens the connection wizard.
Configure the connection. Then click on TEST. If the connection succeeds, close the wizard
Open the .udl file in a text editor. It contains a valid connection string.
Copy the connection string from the text editor into your Visual Studio data source string.

Resources