Missing assembly binding redirect from StackExchange.Redis 2.0.513 package - azure

I am getting the following exception when trying to use the latest Nuget package StackExchange.Redis in Cloud Service for .Net 4.7
System.InvalidOperationException: The assembly for System.Buffers and System.IO.Pipelines could not be loaded; this usually means a missing assembly binding redirect - try checking this, and adding any that are missing; note that it is not always possible to add this redirects - for example 'azure functions v1'; it looks like you may need to use 'azure functions v2' for that - sorry, but that's out of our control
at Pipelines.Sockets.Unofficial.Helpers.g__Throw|5_0(String msg)
at Pipelines.Sockets.Unofficial.Helpers.AssertDependencies()
at StackExchange.Redis.ConnectionMultiplexer.Connect(String configuration, TextWriter log)
at ...
This is coming from a Worker Role in Cloud Service, which is referencing to a class library referencing to this package. Also, I am not able to reproduce this locally. It happens only after deployment to the VM/Cloud Service.
What am I missing?

Add assembly redirect:
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" />
<bindingRedirect oldVersion="4.0.2.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
Found the details here.

Related

HTTP Error 500.37 - ANCM Failed to Start Within Startup Time Limit - Still not resolved after increasing Startup Time Limit

I am attempting to deploy new services to Azure App Service and am getting the following error message on the services:
After doing some research, it seems the most common approach to this problem is to increase the startupTimeLimit, which I have done a couple times and is not resolving this issue.
Here is the section of the web.config file containing the startupTimeLimit increase:
<aspNetCore processPath="bin\Debug\netcoreapp3.1\TemplateService.Api.exe" arguments="" stdoutLogEnabled="false" hostingModel="InProcess" startupTimeLimit="900">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
I originally attempted to increase to 300 seconds but that didn't fix it, so I went ahead and upped it to 900 seconds just to see if I could get past this error (which I didn't).
Are there any other ways to resolve this issue if this increase is not fixing it?
Please restore your web.config to its original state. The settings of
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
are not required.
I can't tell you the reason directly, but I can help you find the error log of the problem. When you see the error log, you can search for it by google to solve the problem.
Troubleshooting
Method 1.
Add ASPNETCORE_ENVIRONMENT=Development on portal, not web.config file. It will show more details in page.
Method 2.
Add stdoutLogFile=".\logs\stdout" in web.config file. And you can find log file in scm site.
For more details, you can read: Enabling ASP.NET Core stdout log (Windows Server).
If you also can't find the reason, you need to use method 3.
Method 3.
① You can Collect .NET Profiler Trace on portal.
For more details, you can refer my answer in below post.
Azure - Unhandled Exception: System.IO.FileNotFoundException
② And you also can check application event logs.

Configuration exception thrown when ServiceStack RegisterLicense method is called

When invoking this method, Licensing.RegisterLicense(licenseKey);, I get a initialization exception with the following inner error:
Message=Unrecognized configuration section DbProviderFactories. (C:\Actevis\Development\Actevis.Cloud\SqlLiteTestBed\bin\Debug\SqlLiteTestBed.vshost.exe.Config line 16)
Here is the offending config section:
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
I have tried adding an appsetting section to the app.config file but the same error still appears. Since the DbProviderFactories are not present in the app.config file I assume that the section is injected by ServiceStack.
I am trying to use ServiceStack.Ormlite.SQLite32. This is the nuget package that was installed. I have copied the license file a few times to make sure that there was not problem there.
Thanks
Thanks for your reply. I was able to figure out what was happening:
When installing the ServiceStack.Ormlite.Sqlite32 package, Entity framework and EntityFramework for SQLServer is also installed. There seems to be an issue when using Sqlite and EntryFramework for Sql Server together. I deleted all the entity framework related DGG's from the project and removed the sections from the app.config file. This has fixed the problem.
The issue is that you're Web.config is invalid and the error gets thrown when first trying to access the Web.config, which is what ServiceStack does when it looks for the servicestack:license app setting.
Note: the <DbProviderFactories> should be declared inside <system.data> tags:
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
</DbProviderFactories>
</system.data>
This was caused by the Web.config.transforms in the dependent System.Data.SQLite.x86 package. This could also be a bug in NuGet's web.config.transform as the rule says to add it under <system.data>...</system.data> but it's being added to the top-level creating an invalid Web.config configuration.
The entire config isn't needed for OrmLite so can be removed. I've also reached out to the SQLite maintainer to notify him about this issue so hopefully will be resolved in future issues.
Whilst I'm looking at making changes to OrmLite's Sqlite packages to embed the dlls and remove the dependency to the Sqlite packages that's causing this error.

Use latest version of Npgsql with ServiceStack.OrmLite.PostgreSQL

I am using ServiceStack.OrmLite 4.0.9 (with PostgreSQL, which uses Npgsql). It appears that ServiceStack requires a specific version of Npgsql (2.0.11). However, there is a significant bug in Npgsql 2.0.11 (see pull request here and StackOverflow question here). I believe the bug was fixed in Npsql 2.0.12+.
How can I use a later version of Npgsql with ServiceStack.OrmLite.PostgreSQL?
I have tried to simply replace the Npgsql 2.0.11 dll file with the latest version (2.0.14.3, at time of writing), but this causes ServiceStack.OrmLite to throw the following exception:
System.IO.FileLoadException was unhandled by user code
HResult=-2146234304
Message=Could not load file or assembly 'Npgsql, Version=2.0.11.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=ServiceStack.OrmLite.PostgreSQL
FileName=Npgsql, Version=2.0.11.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7
FusionLog=Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
StackTrace:
at ServiceStack.OrmLite.PostgreSQL.PostgreSQLDialectProvider.CreateConnection(String connectionString, Dictionary`2 options)
at ServiceStack.OrmLite.OrmLiteConfig.ToDbConnection(String dbConnectionStringOrFilePath, IOrmLiteDialectProvider dialectProvider)
at ServiceStack.OrmLite.OrmLiteConnection.get_DbConnection()
at ServiceStack.OrmLite.OrmLiteConnection.Open()
at ServiceStack.OrmLite.OrmLiteConnectionFactory.OpenDbConnection()
at ServiceStack.Service.get_Db()
at XYZ.Post(Abc req) in XYZ.cs:line 45
at lambda_method(Closure , Object , Object )
at ServiceStack.Host.ServiceRunner`1.Execute(IRequest request, Object instance, TRequest requestDto)
ServiceStack.OrmLite.PostgreSQL has probably been compiled against a specific version of Npgsql. Is it possible to use a different version of Npgsql? Or does anyone know when ServiceStack.OrmLite.PostgreSQL will update the version of Npsql it compiles against?
In your config file, add a binding redirect to the version of Npgsql you want to use.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.14.2" newVersion="2.0.14.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>

MaxBufferPoolSize and MaxBufferSize?

This is my first post to Stack Overflow so please apologies if there is any non-conformity in it.
Question
I have developed a Windows Azure based site (similar to eBay) and hosted it on Azure platform. I have deployed multiple instances of web role with Azure caching enabled. Till last week everything was going fine but suddenly product search page started freezing while loading the data from db. It hangs only for specific categories which returns huge amount of data.
I read somewhere that we should enable localCache and transportProperties if we are expecting large messages. Hence I modified datacache item in my web.config as below but no luck. The page still hangs for those categories!
Could somebody please tell me what is wrong in following and show me some pointers?
<dataCacheClient name="default" channelOpenTimeout="20000" maxConnectionsToServer="4" requestTimeout="30000">
<localCache isEnabled="true" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
<clientNotification pollInterval="300" maxQueueLength="10000"/>
<transportProperties connectionBufferSize="64000" maxBufferPoolSize="5242880"
maxBufferSize="1242880" maxOutputDelay="2" channelInitializationTimeout="60000"
receiveTimeout="600000"/>
<hosts>
<host name="<<AZURE CACHE URL>>" cachePort="22233" />
</hosts>
<securityProperties mode="Message">
<messageSecurity
authorizationInfo="<<KEY>>">
</messageSecurity>
</securityProperties>
</dataCacheClient>
<dataCacheClient name="SslEndpoint" channelOpenTimeout="20000" maxConnectionsToServer="4" requestTimeout="30000">
<localCache isEnabled="true" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
<clientNotification pollInterval="300" maxQueueLength="10000"/>
<transportProperties connectionBufferSize="64000" maxBufferPoolSize="15242880"
maxBufferSize="5242880" maxOutputDelay="2" channelInitializationTimeout="60000"
receiveTimeout="600000"/>
<hosts>
<host name="<<AZURE CACHE URL>>" cachePort="22243" />
</hosts>
<securityProperties mode="Message" sslEnabled="true">
<messageSecurity
authorizationInfo="<<KEY>>">
</messageSecurity>
</securityProperties>
</dataCacheClient>
My dev env,
Azure SDK 1.8 (Oct 12), SQL Server 2008 R2, ASP.Net MVC 3
UPDATE
Today I deployed a build with CustomerErrors off to see the if it throws any exception, and this is what I got.
Thanks in advance
ND
I would advice to first find out which component is truly causing your intermittent slowdowns. Is it cache or is it SQL Azure?
If it is indeed cache, and since you're using Azure Shared Cache (previously known as Azure AppFabric Cache)
I would suggest looking at Dedicated cache as a solution instead of Shared cache. Performance of Shared Cache can sometimes be... unpredictable since it is a multi-tenant service and data travels over a network.

azure cache preview

I tried the new azure preview that came with the new sdk on my computer.
I put a worker role with cache preview and put co-located role with 30% cache size.
on my controller i put this code:
[OutputCache(Duration=int.MaxValue, VaryByParam="none")]
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
ViewBag.Id = Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CurrentRoleInstance.Id;
return View();
}
now i ran the worker role via the emulator with 4 instances. the result was that every time i saw a different id - which mean the output cache never work with all the 4 instances ( to be clear i configure the output cache to work with the cache preview).
Only when i put an extra cache worker role as dedicated role everything start to work like it should be.
My questions is:
Do i need the extra worker role to actually make the cache preview to work ok? - which mean the trade off of not working with azure appfabric cache is putting extra machine
Did i do something work and it should work with the web roles as co located roles?
thanks
edit:
this another section of my web.config
<dataCacheClients>
<tracing sinkType="DiagnosticSink" traceLevel="Error" />
<dataCacheClient name="default">
<autoDiscover isEnabled="true" identifier="NugetTest" />
<!--<localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />
</dataCacheClient>
if my identifier have NugetTest ( which is my web roles - which i have 4) every time i switch machine i get a different cache. if i change the identifier to my worker role i get the result
Can you add applicationName tag in the provider configuration in web.config of you app? If this is not added, instances will not share the cache across. Please note the applicationName tag.
This should be added for the web.config of webrole in both dedicated or colocated cache scenario.
Please reply if this solves your issue.
<caching>
<outputCache defaultProvider="DistributedCache">
<providers>
<add name="DistributedCache" type="Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider, Microsoft.Web.DistributedCache" cacheName="<cacheName>" applicationName ="<anyName>" dataCacheClientName="<dataCacheClientName>" />
</providers>
</outputCache>
</caching>
I'm unable to reproduce this issue. I always see the same instance, and I'm using Ctrl+F5 in the browser (thus rule out browser cache). PLease make sure you've configured output cache provider as described on http://www.windowsazure.com/en-us/develop/net/how-to-guides/cache/.
<!-- If output cache content needs to be saved in a Windows Azure
cache, add the following to web.config inside system.web. -->
<caching>
<outputCache defaultProvider="DistributedCache">
<providers>
<add name="DistributedCache"
type="Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider, Microsoft.Web.DistributedCache"
cacheName="default"
dataCacheClientName="default" />
</providers>
</outputCache>
</caching>
Best Regards,
Ming Xu.

Resources