Trouble getting Caching working inside Azure Web Sites - azure

I'm trying to get Caching working on my Windows Azure Website. The caching is configured on one of my Worker Roles.
I used this article to get started: http://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/
Initially I've had trouble to get the Azure Cache Client dll working because of missing assembly errors.
Could not load file or assembly 'Microsoft.WindowsAzure.ServiceRuntime, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'msshrtmi, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Though I've been helped by this article to resolve this: http://www.thedailyparker.com/PermaLink,guid,0be6425e-b509-4122-af01-7086ce2f811e.aspx
But next I'm getting a SEHException which sounds like a configuration problem. Though I've no idea what I'm missing.
Exception Details:
[SEHException (0x80004005): External component has thrown an exception.]
RdGetApplicationConfigurationSetting(UInt16* , UInt16** ) +0
RoleEnvironmentGetConfigurationSettingValueW(UInt16* pszName, UInt16* pszDest, UInt32 cchDest, UInt32* pcchRequiredDestSize) +47
Microsoft.WindowsAzure.ServiceRuntime.Internal.InteropRoleManager.GetConfigurationSetting(String name, String& ret) +91
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(String configurationSettingName) +54
Microsoft.ApplicationServer.Caching.AzureCommon.TopologyHelper.TryGetServiceConfigurationSetting(String value, String& result) +40
Microsoft.ApplicationServer.Caching.AzureCommon.DiagnosticsUtility.GetDiagnosticLevel(String propertyName) +47
Microsoft.ApplicationServer.Caching.AzureCommon.DiagnosticsUtility.GetClientLogLevel() +20
Microsoft.ApplicationServer.Caching.AzureClientHelper.RoleUtility.ReadClientLogLevel() +5
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +192
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +108
Microsoft.ApplicationServer.Caching.DataCacheFactoryConfiguration.Initialize(String clientName) +205
Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFactoryConfiguration(String dataCacheClientName) +77
Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.CreateInternalProvider(IHttpRuntime httpRuntime, OutputCacheInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +28
Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.GetInternalProvider() +148
Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.Get(String key) +11
System.Web.Caching.OutputCache.Get(String key) +56
System.Web.Caching.OutputCacheModule.OnEnter(Object source, EventArgs eventArgs) +9717054
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
I hope someone can help me in the right direction.

You cannot access Windows Azure Caching from a Web Site. You can only access it from a Web Role or Worker Role.
Have you tried Windows Azure Shared Caching in your Web Site? This should work (haven't tried this myself in a Web Site).

Related

OpenIdDict 3.0 error from ASP.NET Core 3.1 web application

I am hosting my ASP.NET Core 3 web application in Azure, whenever I do a new publish to Azure, it works as expected. However, the next day, the site is down, then I need to republish again, then it works, then it is down again the following day.
The full error message from Azure is this:
Application '/LM/W3SVC/975757150/ROOT' with physical root 'D:\home\site\wwwroot' hit unexpected managed exception, exception code = '0xe0434352'. First 30KB characters of captured stdout and stderr logs:
Unhandled exception.
Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException: Keyset does not exist
at Internal.NativeCrypto.CapiHelper.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
at System.Security.Cryptography.RSACryptoServiceProvider.get_SafeProvHandle()
at System.Security.Cryptography.RSACryptoServiceProvider.get_SafeKeyHandle()
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 keySize, CspParameters parameters, Boolean useDefaultKeySize)
at System.Security.Cryptography.RSACryptoServiceProvider..ctor(CspParameters parameters)
at Internal.Cryptography.Pal.CertificatePal.<>c.b__66_0(CspParameters csp)
at Internal.Cryptography.Pal.CertificatePal.GetPrivateKey[T](Func2 createCsp, Func2 createCng)
at Internal.Cryptography.Pal.CertificatePal.GetRSAPrivateKey()
at Internal.Cryptography.Pal.CertificateExtensionsCommon.GetPrivateKey[T](X509Certificate2 certificate, Predicate1 matchesConstraints) at System.Security.Cryptography.X509Certificates.RSACertificateExtensions.GetRSAPrivateKey(X509Certificate2 certificate) at Microsoft.IdentityModel.Tokens.X509SecurityKey.get_PrivateKey() at Microsoft.IdentityModel.Tokens.X509SecurityKey.get_PrivateKeyStatus() at Microsoft.Extensions.DependencyInjection.OpenIddictServerBuilder.AddSigningKey(SecurityKey key) at Microsoft.Extensions.DependencyInjection.OpenIddictServerBuilder.AddSigningCertificate(X509Certificate2 certificate) at ackids.Startup.<ConfigureServices>b__6_6(OpenIddictServerBuilder options) in D:\ackidsRepos\ackids\ackids\Startup.cs:line 154 at Microsoft.Extensions.DependencyInjection.OpenIddictServerExtensions.AddServer(OpenIddictBuilder builder, Action1 configuration)
at ackids.Startup.ConfigureServices(IServiceCollection services) in D:\ackidsRepos\ackids\ackids\Startup.cs:line 118
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.g__Startup|0(IServiceCollection serviceCollection)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.b__0(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass12_0.b__0(HostBuilderContext context, IServiceCollection services)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at ackids.Program.Main(String[] args) in D:\ackidsRepos\ackids\ackids\Program.cs:line 16
Process Id: 14164.
File Version: 13.1.21196.18. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: 0a2e366eaf4d29b24b9a98e5782a04bef573189e*
The reason for this error might be the The OpenIddict versions that you are using which are not compatible for ASP.NET 3.1.
Try upgrading to the latest versions.

Exception of type 'System.ServiceModel.FaultException' occurs while registering plugin in CRM 2013

I am getting the following error when trying to register a plugin in CRM 2013:
Unhandled Exception:
System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Assembly can not be loaded.
DETAIL
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Xrm.Sdk.IOrganizationService.Create(Entity entity)
at Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy.CreateCore(Entity entity)
at PluginRegistrationTool.RegistrationHelper.RegisterPlugin(CrmOrganization org, CrmPlugin plugin)
at PluginRegistrationTool.PluginRegistrationForm.btnRegister_Click(Object sender, EventArgs e)
I think the problem is that you are using the older version for Microsoft.Xrm.Sdk, Version=5.0.0.0, you should use version 6. So download the latest SDK from the following link http://www.microsoft.com/en-ca/download/details.aspx?id=40321, replace your dll reference in the plugin project, rebuild and try to update the plugins.
solved
Actually it was dll file of custom workflow written in C# not plugin dll...
This exception was thrown because , i was registering it on disk. Later i tried it to register on database and it worked fine...
I suggest all of you to register your plugins on disk and workflows on database.
hope this will solve if anyone face this problem in future.
dlls are registered using plugin registration tool. you can find in link (download)

dynamics CRM 2011 and VS 2012 SDK, cannot deploy to an existing solution (plugin error)

I have to make changes to an existing solution of CRM 2011.
Therefore I am using VS 2012 and the CRM 2011 SDK.
The VS CRM Package consists of some webresources and 2 plugins.
I haven't made any changes to the plugins but it seems they are responsible for the error.
When I want to deploy the solution via VS 2012 to the existing solution I am getting following error:
Error registering plugins and/or workflows. An unexpected error
occurred. C:\Program Files
(x86)\MSBuild\Microsoft\CRM\Microsoft.CrmDeveloperTools.12.targets 176 4
I've enabled tracing on my Server and in the logfile the following is stated:
Web Service Plug-in failed in SdkMessageProcessingStepId: {C03B8615-ECD8-DB11-B397-0019B9204DA9}; EntityName:
sdkmessageprocessingstep; Stage: 30; MessageName: Create;
AssemblyName: Microsoft.Crm.Extensibility.InternalOperationPlugin,
Microsoft.Crm.ObjectModel, Version=5.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35; ClassName:
Microsoft.Crm.Extensibility.InternalOperationPlugin; Exception:
Unhandled Exception: System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. at
System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
arguments, Signature sig, Boolean constructor) at
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object[] parameters, Object[] arguments) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object
target, Object[] values) at
Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider
serviceProvider) at
Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext
context) at
Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext
context) Inner Exception: System.NullReferenceException: Object
reference not set to an instance of an object. at
Microsoft.Crm.Platform.SolutionAwareComponents.ComponentStateTransitionFactory.CreateStateTransition(FactoryInput
input, ComponentStateTransitionActionFactory actionFactory) at
Microsoft.Crm.BusinessEntities.BusinessProcessObject.DoCreate(IBusinessEntity
entity, ExecutionContext context)
I've wasted hours with finding the solution to this problem - but without luck.
If I deploy the CRM-Package to a newly created solution it is working.
Can anyone help with this please?
Thanks
edit:
I am on rollup 15, but tried it on different rollups as well (11,13,17..)
I've also tried it with different machines (CRM Server and Client machines)

Error associating Azure SQL database with Azure website: System.NullReferenceException: Object reference not set to an instance of an object

I am having a strange error with publishing my website to Azure. I published it to the service using VS 2010 but then have run into this error in connecting my database to the website. The login page works, as do most of the pages on the site, even those that rely on the very same database. The page with the issue comes up with the following text:
Server Error in '/' Application.
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.]
MAO.Controllers.ReviewController.Index() +603
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +214
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
System.Web.Mvc.Controller.ExecuteCore() +106
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +34
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +48
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
The error occurs within the following section of code:
public ActionResult ShortDateResponse(int reviewId, int questionId, string response) {
if (string.IsNullOrEmpty(response)) {
var answer = repository.GetAnswerByQuestionId(reviewId, questionId);
if (answer != null) {
repository.DeleteAnswerById(answer.Id);
}
} else {
try {
DateTime date = DateTime.ParseExact(response, "MM/yyyy", CultureInfo.InvariantCulture);
repository.ShortDateResponse(reviewId, questionId, date);
} catch (Exception fe) {
throw new ArgumentException("Date format should be MM/yyyy", fe);
}
}
return Json(new {
success = true,
error = "none"
});
}
on this line:
DateTime date = DateTime.ParseExact(response, "MM/yyyy", CultureInfo.InvariantCulture);
As such, it seems to me the code is not responsible.
I have tried uploading the database to Azure multiple different ways, and according to the various Microsoft tutorials, and have reviewed others who have presented very similar questions on SO and other places. At this point I am not sure how to move forward, so I'm asking.
Initially, I used SQL Management Studio 2008R's "Extract Data-Tier Application" and "Import Data-Tier Application" to load the schema for the database, then "Export Data" and "Import Data" to load up the data onto the server. I ensured that the commandtimeout variable was sat to 0 for all tables so nothing would get lost along the way, and sure enough, everything showed up on the Azure database.
When this presented the aforementioned error, I attempted to use the "Generate scripts" to upload the schema, in case there had been some error with my previous process. I then used Export/Import Data to put the data on the website. I received the same error.
This website does work properly on internal servers, an has been deployed successfully elsewhere, but I'd like to migrate to Azure if possible. Also, I have checked the uploaded website linked to local SQL servers and it has worked properly, so the issue lies in the upload of the SQL database to Azure servers.
I am aware that many people with this error have been able to solve it by editing their connection strings within web.config. I have looked into this, and have manually edited my connection string via Filezilla to the format put forth on various websites, to no avail.
I would really appreciate any insights you have, and let me know if you need more details. Thank you!
One thought is that it might be the firewall rule on the SQL Azure instance. In the Windows Azure Management Portal, go to the "Configure" page for that SQL Azure server. Is it set to "Yes" for allow windows azure services?
Can you also post the code for the controller action MAO.Controllers.ReviewController.Index() so we can see where the null reference exception occurs?

Sharepoint Word Automation Services Exception

I am trying to do a server side doc/docx to pdf conversion using Word Automation Services. I am using the basic sample from MSDN, Link: http://msdn.microsoft.com/en-us/library/ff742315.aspx and encounter an obscure error every time ConversionJob's Start() method is called. Here's the exception;
Source: mscorlib
Message: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
InnerException: System.ServiceModel.FaultException: An error occurred when verifying security for the message.
StackTrace: Server stack trace: at System.ServiceModel.Channels.SecurityChannelFactory1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout) at System.ServiceModel.Channels.SecurityChannelFactory1.SecurityRequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.IdentityModel.Protocols.WSTrust.IWSTrustContract.Issue(Message message) at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst, RequestSecurityTokenResponse& rstr) at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst) at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForContext(Uri context, Boolean bearerToken, SecurityToken onBehalfOf, SecurityToken actAs, SecurityToken delegateTo) at Microsoft.SharePoint.SPSecurityContext.<>c_DisplayClass7.b_6() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurityContext.GetProcessSecurityTokenForServiceContext() at Microsoft.SharePoint.SPSecurityContext.SecurityTokenForServiceContext(Uri contextUri) at Microsoft.SharePoint.SPChannelFactoryOperations.InternalCreateChannelActingAsLoggedOnUser[TChannel](ChannelFactory1 factory, EndpointAddress address, Uri via) at Microsoft.SharePoint.SPChannelFactoryOperations.CreateChannelActingAsLoggedOnUser[TChannel](ChannelFactory1 factory, EndpointAddress address) at Microsoft.Office.Word.Server.Service.ConfigChannelFactory1.CreateChannel() at Microsoft.Office.Word.Server.Service.WordServiceApplicationProxy.AddJob(Ucid ucid, Nullable1 subscriptionId, SPUserToken userToken, ConversionJobSettings settings, String name) at Microsoft.Office.Word.Server.Conversions.ConversionJob.Start() at VisualWebPartProject1.VisualWebPart1.VisualWebPart1UserControl.Page_Load(Object sender, EventArgs e)
I tried the same code inside one of our sharepoint sites, still got the same error. Trying this inside a Wcf Service has same result. I made a visual web part for this and same error. Changing user accounts or RunWithElevatedPrivileges didn't help either.
Since the sample requires Microsoft.Sharepoint and Microsoft.Office.Word.Server.Conversions namespaces, I have to run this code on some server having sharepoint installed. So IMHO, the time skew issue is not related as the code is ran over the same server where Word Automation Services are present. I expect some configuration problems on the sharepoint server side, but I don’t know what to check.
Let me know if any other details are required, thanks.
Without having more specifics around the code you're running it's hard to say. Take a look at the overall Word Automation Services content in the SDK.
Also, check out the topics under "Configuring Word Automation Services for Development" in the SDK in particular.

Resources