CLR Can't find a type, even though it's in the same assembly - system.diagnostics

I'm troubleshooting a WCF problem in our application, and turned on WCF tracing with the WCF Service Configuration Editor in VS 2010, which added the following sharedListener to the web.config:
<sharedListeners>
<add initializeData="D:\Logs\CRCCustomerService\Web_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
Now, when I take steps to reproduce my error, I'm getting an exception thrown from the System.Diagostics library saying that it can't find XmlWriterTraceListener:
Stack Trace:
System.TypeInitializationException: The type initializer for 'System.ServiceModel.DiagnosticUtility' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Couldn't find type for class System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
at System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData)
at System.Diagnostics.TypedElement.BaseGetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElementsCollection.GetRuntimeObject()
at System.Diagnostics.TraceSource.Initialize()
at System.Diagnostics.TraceSource.get_Listeners()
And it goes on for several more lines, but this establishes the context.
My question is, since, according to ObjectBrowser and Reflector, XmlWriterTraceListener is a member class of the same assembly that System.Diagnostics is, how can it NOT not be able to find it?
And secondly, since every single line in the exception stack comes from system code, how on earth do I begin to debug the root cause here?

Are you using .NET 4.0?
If not, you have to beware the service config utility. It will hard code the version of the listener to 4.0 and you'll need to manually change your web.config

Related

The data protection operation was unsuccessful

I'm trying to get the sample MVC application from Kentor AuthServices deployed to Azure and using Okta as the IDP. I've jumped a few hurdles but have stumbled on the CryptographicException "The data protection operation was unsuccessful". I'm unsure how to resolve it.
When this occurs the URL in the browser is https://mysite.azurewebsites.net/AuthServices/Acs
Any assistance is appreciated, thanks.
Below is the kentor section of my web.config. I don't have an identity server so removed all the federation config..
<kentor.authServices entityId="https://mysite.azurewebsites.net/AuthServices"
returnUrl="https://mysite.azurewebsites.net/"
authenticateRequestSigningBehavior="Never">
<identityProviders>
<add entityId="http://www.okta.com/1111111"
allowUnsolicitedAuthnResponse="true" binding="HttpRedirect"
metadataLocation="https://dev-11111.oktapreview.com/app/1111111/sso/saml/metadata"
loadMetadata="true">
<signingCertificate fileName="~/App_Data/okta.cert" />
</add>
</identityProviders>
Let me know if I can provide any further info to assist you in assisting me!
It was actually an Azure issue as Anders points out. The fix was to add the following to web.config:
<system.identityModel>
<identityConfiguration>
<securityTokenHandlers>
<add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</securityTokenHandlers>
</identityConfiguration>
</system.identityModel>
Looks like a bug in Kentor.AuthServices. I've recently done some rewriting which makes use of data protection API so something might be wrong there. Please file an issue at the github site and include the stack trace of the exception as well as information on what API module you are using (MVC, HttpModule or OWIN).

AppFabric: Cache host cannot load provider assembly for read-through and write-behind

I want to try out the new read-through/write-behind feature of AppFabric 1.1. I implemented a provider that references some other own assemblies, according to http://msdn.microsoft.com/en-us/library/hh361698%28v=azure.10%29.aspx. All are signed and compiled for AnyCPU. I put the provider and all referenced assemblies in the GAC (see http://msdn.microsoft.com/en-us/library/hh361703(v=azure.10).aspx). Then I stopped the cache cluster and created a new cache with the read-through and write-behind options passing the full name of my provider assembly (that I got from gacutil -l).
New-Cache ReadThroughWriteBehindCache -ReadThroughEnabled true -WriteBehindEnabled true
-WriteBehindInterval 60 -ProviderType "CachingDemo.Provider, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=236fd28d53a6f1ad" -ProviderSettings #{"connectionString"="Data Source=.;Initial
Catalog=Demo;Persist Security Info=True;User
ID=sa;Password=password;MultipleActiveResultSets=True";"logFilePath"="C:\Logs\CacheProvider"}
When starting the cache cluster again I got a timeout and following error message in the event log:
AppFabric Caching service crashed with exception Microsoft.ApplicationServer.Caching.DataCacheException:
ErrorCode<ERRCMS0007>:SubStatus<ES0001>:Provider "CachingDemo.Provider, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=236fd28d53a6f1ad" instantiation failed: The given assembly name
or codebase was invalid. (Exception from HRESULT: 0x80131047) ---> System.IO.FileLoadException:
The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
What could possibly be wrong? I triple-checked the assembly name. The name I passed when creating the cache is exactly the same as the one I get from gacutil -l. The assembly is AnyCPU what should work in any case. Since the assembly is not even loaded errors inside the assembly can be ruled-out.
The reason was that the provider type information was not correctly passed when creating the cache. I assumed that AppFabric would find the provider itself (by reflection). But we have to add the provider type in the ProviderType argument. Additionaly between the type and the assembly information only a comma is allowed (not a comma with a space for example):
New-Cache ReadThroughWriteBehindCache -ReadThroughEnabled true -WriteBehindEnabled true
-WriteBehindInterval 60 -ProviderType CachingDemo.Provider.Provider,CachingDemo.Provider,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=236fd28d53a6f1ad"
-ProviderSettings #{"connectionString"="Data Source=.;
Initial Catalog=Demo;Persist Security Info=True;
User ID=sa;Password=password;MultipleActiveResultSets=True";
"logFilePath"="C:\Logs\CacheProvider"}

Configure Active Directory in MVC3 project

I have a problem deploying a MVC3 project IIS server, the project runs well in my local machine, but not in the server the errors say's this
Parser Error Message: The supplied credential is invalid.
This is the line of configuration of my merbership Provider
<add name="MembershipADProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="AtentoCNEHoraExtra" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" />
What could be wrong???
I found the solution to my problem, I have to modify the identity of the process model associated with the pool .NET 4 in the configuration on my IIS
The value that has by default was ApplicationPoolIdentity and I have to changed to NetworkService
This configuration can be made in ISS --> Application Pool ----> .Net 4---> Advanced Settings --> Process Model
I hope that helps to others

Unable to serialize the session state, which is related to System.Data.Linq. EntitySet

Recently I am playing with the Windows Server 2008,
and would like to make some configuration for my web application.
I have changed the Session State for my application to "State Server" so it can make use of more work process (Now it is set to 4).
Afterwards I have got this error when I attempt to login to the application.
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
I suspect it is related to the EntitySet I have declared because I see this in the Stack Trace when the error occur:
[SerializationException: Type
'System.Data.Linq.EntityRef`1[[CtcSystem.Domain.Entities.Account.Account,
CtcSystem.Domain, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null]]' in Assembly 'System.Data.Linq, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as
serializable.]
I have used [Serializable] tag on my classes,
so is there any way I have to do to make the EntitySet serializable so that the application can run under State Server?
Thanks
Best way is to implement the ISerializable interface on a partial class...

Windows Workflow foundation activity + migration to visual studio 2010

I created a custom worflow activity that inherit from CompositeActivity as shown below using VS2008
public class CustomWorkflowActivity : System.Workflow.ComponentModel.CompositeActivity
I am able to write the below with no problems
<GS0:People365WorkflowActivity x:Class="People365.Workflows.Advance_Loan_1WF"
x:Name="Advance_Loan_1"
xmlns:GS0="clr-namespace:WorkflowEngine.Engine;assembly=WorkflowEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d2bf1cbcd6bbcd82"
xmlns:GS1="clr-namespace:WorkflowEngine.ActivityLibrary;assembly=WorkflowEngine.ActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d2bf1cbcd6bbcd82"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<GS1:People365SequenceActivity x:Name="Activity2" WorkflowTemplateActivityId="a6b6327b-c27f-459e-a933-c3cf66ab711f" IsMandatoryActivity="False"></GS1:People365SequenceActivity>
</GS0:People365WorkflowActivity>
after migrating the application to VS2010, the below errors appear
The type 'People365WorkflowActivity' does not support direct content.
Type 'WorkflowEngine.Engine.People365WorkflowActivity' does not have a suitable TypeConverter or content property to handle this content.
Any help is very appreciated.
use the bellow:
<GS0:People365WorkflowActivity x:Class="People365.Workflows.Advance_Loan_1WF"
x:Name="Advance_Loan_1" xmlns:GS0="clr-
namespace:WorkflowEngine.Engine;assembly=WorkflowEngine,Version=1.0.0.0,
Culture=neutral,
PublicKeyToken=d2bf1cbcd6bbcd82" xmlns:GS1="clr-
namespace:WorkflowEngine.ActivityLibrary;assembly=WorkflowEngine.ActivityLibrary,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=d2bf1cbcd6bbcd82"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<GS0:People365WorkflowActivity.Activities>
<GS1:People365SequenceActivity x:Name="Activity2"
WorkflowTemplateActivityId="a6b6327b-c27f-459e-a933-c3cf66ab711f" IsMandatoryActivity="False">
</GS1:People365SequenceActivity>
</GS0:People365WorkflowActivity.Activities>
</GS0:People365WorkflowActivity>

Resources