I m using the local system to test session on windows azure. I have done the following config in web.config
<appSettings>
<!-- account configuration -->
<add key="TableStorageEndpoint" value="http://127.0.0.1:10002/devstoreaccount1/" />
<add key="BlobStorageEndpoint" value="http://127.0.0.1:10000/devstoreaccount1/" />
<add key="AccountName" value="devstoreaccount1" />
<add key="AccountSharedKey" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" />
<add key="DefaultMembershipTableName" value="Membership" />
<add key="DefaultRoleTableName" value="Roles" />
<add key="DefaultSessionTableName" value="Sessions" />
<add key="DefaultProviderApplicationName" value="ProviderTest" />
<add key="DefaultProfileContainerName" />
<add key="DefaultSessionContainerName" />
</appSettings>
<system.web>
<sessionState mode="Custom" customProvider="TableStorageSessionStateProvider">
<providers>
<clear />
<add name="TableStorageSessionStateProvider" type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider" />
</providers>
</sessionState>
</system.web>
but now i an getting the following 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: Exception has
been thrown by the target of an
invocation.
Source Error:
Line 39: Line 40:
Line 41: Line 42: Line
43:
Source File:
C:\Users\GizaKarthik\Desktop\SessionDemo\SessionDemo\SessionDemo_WebRole\web.config
Line: 41
Assembly Load Trace: The following
information can be helpful to
determine why the assembly
'Microsoft.WindowsAzure.StorageClient,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' 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].
The reason for the exeption is that i used a corrupted dll. Download the additional c# examples from here . Find asp provides project edit the code in TableStorageSessionstateProvider
find this code
else
{
byte[] items = Convert.FromBase64String(reader.ReadLine());
byte[] statics = Convert.FromBase64String(reader.ReadLine());
int timeout = session.Timeout;
// Deserialize the session
result = DeserializeSession(items, statics, timeout);
}
replace the above code with this
else
{
try // Added try statement
{
// Read Items, StaticObjects, and Timeout from the file
byte[] items = Convert.FromBase64String(reader.ReadLine());
byte[] statics = Convert.FromBase64String(reader.ReadLine());
int timeout = session.Timeout;
// Deserialize the session
result = DeserializeSession(items, statics, timeout);
}
catch (Exception e) // Added catch statement
{
// Return an empty SessionStateStoreData
result = new SessionStateStoreData(new SessionStateItemCollection(),
SessionStateUtility.GetSessionStaticObjects(context),
session.Timeout);
}
}
Then compile and use the dll. It should work like a champ. happy coding!!
Related
I was connected CRM with Plugin registration tool of CRM SDK 2016 whenever i am uploading the downloaded error log file to debugger it's showing "An error occured while parsing the plugin's profile from file" could any suggest me where i am going wrong. The image is showing below:
ErrorImage
Unhandled Exception: System.ArgumentException: Unable to parse the OrganizationServiceFault.
Parameter name: serializedReport
at PluginProfiler.Library.ProfilerUtility.ExtractReport(String serializedReport)
at PluginProfiler.Library.ProfilerUtility.DeserializeProfilerReport(String assemblyFilePath, String logFilePath, Boolean isCrmDataStream)
at PluginProfiler.Library.ProfilerExecutionUtility.RetrieveReport(String logFilePath, Boolean isCrmDataStream)
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.Helper.ParseReportOrShowError(Window window, FileBrowserView profilePathControl, Boolean requireReportParse, ProfilerPluginReport& report)
Inner Exception: System.InvalidOperationException: Message does not contain a serialized value.
at PluginProfiler.Library.ProfilerUtility.ExtractReportFromFault(OrganizationServiceFault fault)
at PluginProfiler.Library.ProfilerUtility.ExtractReport(String serializedReport)
Except this, when log file is downloaded it contains the below error:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Unexpected exception from plug-in (Execute): SamplePlugins.PostCreateContact: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.Detail:
<OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ActivityId>8998bfd9-9637-430e-8c47-998c63d1f0ee</ActivityId>
<ErrorCode>-2147220956</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
<Message>Unexpected exception from plug-in (Execute): SamplePlugins.PostCreateContact: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.</Message>
<Timestamp>2017-11-03T11:49:06.9775603Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource i:nil="true" />
<InnerFault i:nil="true" />
<OriginalException i:nil="true" />
<TraceText>[SamplePlugins: SamplePlugins.PostCreateContact]
[e326c926-0dbe-e711-a94d-000d3af2242b: SamplePlugins.PostCreateContact: Create of contact (Profiled)]</TraceText>
</OrganizationServiceFault>
Below is my .CS file:
using Microsoft.Xrm.Sdk;
using System;
namespace SamplePlugins
{
public class PostCreateContact : IPlugin
{
ITracingService tracingService;
public void Execute(IServiceProvider serviceProvider)
{
tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
tracingService.Trace("Tracing Execute");
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
// The InputParameters collection contains all the data
//passed in the message request.
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
try
{
// Create a task activity to follow up with the account customer in 7 days
Entity followup = new Entity("task");
followup["subject"] = "Send e-mail to the new customer.";
followup["description"] = "Follow up with the customer. Check if there are any new issues that need resolution.";
followup["scheduledstart"] = DateTime.Now;
followup["scheduledend"] = DateTime.Now.AddDays(2);
followup["category"] = context.PrimaryEntityName;
// Refer to the contact in the task activity.
if (context.OutputParameters.Contains("id"))
{
Guid regardingobjectid = new Guid(context.OutputParameters["id"].ToString());
string regardingobjectidType = "contact";
followup["regardingobjectid"] = new EntityReference(regardingobjectidType, regardingobjectid);
}
// Obtain the organization service reference.
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service =
serviceFactory.CreateOrganizationService(context.UserId);
// Create the followup activity
service.Create(followup);
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException(ex.Message);
}
}
}
}
}
I have tried by replacing the PluginProfiler.Solution.zip but the issue still exists.
Thanks.
I recommend you below steps:
Unregister the Plugin assembly & Profiler
Download latest 365 SDK
Register the assembly freshly using new PRT from latest SDK
Install Profiler & try again
Most important - The error log you shared cannot be used to debug using Profiler. It will be different
I'm using WIF to log in my appication. Everything seems to be ok (logging,redirecting to site etc),but when i try use User.Identity.Name in my cod exception is being thrown-User is null.Any ideas what i'm doing wrong? I work on VS 2012. Generated part in web.config looks like below:
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="http://xxx/" />
</audienceUris>
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<trustedIssuers>
<add thumbprint="yyyy" name="https://zzz" />
</trustedIssuers>
</issuerNameRegistry>
</identityConfiguration>
</system.identityModel>
and:
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" />
<wsFederation passiveRedirectEnabled="true" issuer="https://zzz/Secure/FederatedLogin.ashx" realm="http://xxx" requireHttps="false" />
</federationConfiguration>
</system.identityModel.services>
When working with WIF you should use Thread.CurrentPrincipal.Identity.Name instead of User.Identity.Name.
Read more here: http://msdn.microsoft.com/en-us/magazine/ff872350.aspx to learn more about Windows Identity Foundation
Check that the STS includes a Name claim for the user, else User.Identity.Name will be null.
Instead I used:
namespace System.Security.Claims
{
public static class System_Security_Claims_Extensions
{
public static string getName(this ClaimsIdentity ci)
{
foreach (Claim c in ci.Claims)
{
if (c.Type == ClaimTypes.Name)
{
return c.Value;
}
}
return string.Empty;
}
}
}
And used in this context
((ClaimsIdentity)Thread.CurrentPrincipal.Identity).getName()
I'm trying to properly handle and return a 404 for this URL: http://localhost:2867/dd./xml (notice the dot before the slash)
In my current implementation I get 4 exceptions/errors in Application_Error. The first exception returned by Server.GetLastError() is System.Web.HttpException while the next three are null.
I made a bare minimum implementation to reproduce this issue. Here's the code in global.asax.cs:
protected void Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
Server.ClearError();
var routeData = new RouteData();
routeData.Values.Add("controller", "Error");
routeData.Values.Add("action", "Generic");
routeData.Values.Add("area", "");
IController errorController = new ErrorController();
// this line throws System.Web.HttpException is a view is returned from ErrorController
errorController.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
}
The error controller looks like this:
public class ErrorController : Controller
{
public ActionResult Generic()
{
Response.TrySkipIisCustomErrors = true;
Response.StatusCode = (int)HttpStatusCode.NotFound;
return View();
// returning content rather than a View doesn't fire 'System.Web.HttpException' in Application_Error
//return Content("Some error!");
}
}
There are two issues. One is that for the given URL instead of one error in Application_Error I get 3 or 4, and the other is that when returning a view from the ErrorController an exception is thrown on the Execute call line in Application_Start. If a Content("something") is returned instead this internal (to MVC I assume) exception is not triggered.
In order to see the problem you have to be in debug mode and use the development server. When using IIS or IIS Express the error is not caught for some reason. Also, every now and then these errors go away. To get it back to the beginning you have to clean the solution.
If you'd like to play with it here's the bare minimum solution: http://dl.dropbox.com/u/16605600/InvalidUrl.zip
Thank you for your help!
If you're using IIS7+ putting this in the web.config works:
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" responseMode="ExecuteURL" path="/Error/PageNotFound" />
</httpErrors>
</system.webServer>
(Answer from How can I properly handle 404 in ASP.NET MVC?)
Would still be nice to know what is going on in the Application_Error.
You can handle a 404 by changing the customeErrors section in the web.config
There is also a redirectMode attribute which you can use to control the nature of the error page redirection (and avoid the 302) (Read here)
<configuration>
...
<system.web>
<customErrors mode="RemoteOnly"
redirectMode="ResponseRewrite"
defaultRedirect="/ErrorPages/Oops.aspx">
<error statusCode="404" redirect="/ErrorPages/404.aspx" />
</customErrors>
...
http://www.asp.net/hosting/tutorials/displaying-a-custom-error-page-cs
In ASP.net MVC, there is a method you can override to catch all exceptions thrown in a controller. Just override Controller.OnException(...) and you can do custom error handling in there as well. If all of your controllers inherit from a common base controller class, you can put the error handling there.
http://msdn.microsoft.com/en-us/library/system.web.mvc.controller.onexception.aspx
I have an MVC 3 Application that works fine in my dev environment (you
must have heard that before..) I am deploying it to a free hosting
service http://somee.com for testing, the .NET framework is set to
4. I have a custom membership provider. I am able to register a user, as I can see it in the database, but the user never gets authenticated. I always get redirected to the LogOn page, either after the registration or when loging on. I have done a bin deployment and have this dlls in my bin folder:
•System.Web.Mvc
•Microsoft.Web.Infrastructure
•System.Web.Razor
•System.Web.WebPages
•System.Web.WebPages.Razor
•System.Web.Helpers
In the config:
...
<add key="loginUrl" value="~/Account/Logon" />
</appSettings>
....
<membership defaultProvider="ServiceMembershipProvider">
<providers>
<clear/>
<add name="ServiceMembershipProvider"
type="Infrastruture.ServiceMembershipProvider, Infrastruture" />
</providers>
</membership>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
The controllers:
[HttpPost]
public ActionResult Register(FormCollection registration)
{
try
{
if (ModelState.IsValid)
{
var registrationViewModel = MapFormToRegistrationViewModel(registration);
companyManager.RegisterCompany(registrationViewModel);
FormsAuthentication.SetAuthCookie(registrationViewModel.SystemUserViewModel.Email, false);
return RedirectToAction("Welcome", "Home");
}
else
{
ModelState.AddModelError("", "LogId already taken");
}
}
catch(Exception ex)
{
return View("Register", new RegistrationViewModel(dataReferenceService));
}
return View("Register", new RegistrationViewModel(dataReferenceService));
}
/* /Home/Welcome */
[Authorize]
public ActionResult Welcome()
{ return View(); }
Running out of ideas now ...
I know this is an old question but I had a similar problem and found this while searching for the answer.
The solution is to add the following setting to your web config file.
<appSettings>
<add key="enableSimpleMembership" value="false"/>
</appSettings>
The reason this is required is some pre application startup code appears to have some issues with default settings.
A better explaination and the place I found this solution is here
I've created a console application focused on C#3.5 and added a reference to System.Web, System.Configuration and Subsonic.Core. Also have in config file
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="UpdateCotswolds.Properties.Settings.Live_IntegraConnectionString" connectionString="Data Source=POSERVER;Initial Catalog=Live_Integra;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
I've then edited Settings.ttinclude
const string Namespace = "Integra.Data";
const string ConnectionStringName = "UpdateCotswolds.Properties.Settings.Live_IntegraConnectionString";
//This is the name of your database and is used in naming
//the repository. By default we set it to the connection string name
const string DatabaseName = "Live_Integra";
And dragged in the tt files.
When they run I'm getting the error...
Error 2 Running transformation: System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at Microsoft.VisualStudio.TextTemplating47D0892A160210D689C6B90986A9AE0D.GeneratedTextTransformation.LoadTables() in c:\Programming\UpdateCotswolds\UpdateCotswolds\SQLServer.ttinclude:line 134
at Microsoft.VisualStudio.TextTemplating47D0892A160210D689C6B90986A9AE0D.GeneratedTextTransformation.TransformText() in c:\Programming\UpdateCotswolds\UpdateCotswolds\ActiveRecord.tt:line 23
at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)
This is the line in question...
var pkColumn=tbl.Columns.SingleOrDefault(x=>x.Name.ToLower().Trim()==tbl.PrimaryKey.ToLower().Trim());
I'm guessing I'm making a silly mistake and hopefully someone can set me straight...
Thanks in advance...
It appears that a certain table has more than one primary key? Can you post your schema up?
Or maybe your PK and FK are names the exact same and SS is getting confused.
Maybe you can play around with the string[] ExcludeTables = new string[]{}; property found under "Settings.ttinclude" until it works and provide the schema for that one table.