Print Page | Close Window

Type cannot be added to list of known types

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4180
Printed Date: 21-Jan-2026 at 7:46pm


Topic: Type cannot be added to list of known types
Posted By: gregweb
Subject: Type cannot be added to list of known types
Date Posted: 15-Jun-2013 at 4:52am
I have been playing around with Code Contracts lately.

In the Client project, it works fine.

However, when I add a Code Contract to a class in the Domain Model project, I get the following error:

System.InvalidOperationException was caught Message=Type 'System.Diagnostics.Contracts.RuntimeContractsFlags' cannot be added to list of known types since another type 'System.Diagnostics.Contracts.RuntimeContractsFlags' with the same data contract name 'http://schemas.datacontract.org/2004/07/System.Diagnostics.Contracts:RuntimeContractsFlags' is already present.

The error is thrown at runtime when the user tries to log on. (The workaround is simply turning off runtime checking.)

Greg



Replies:
Posted By: kimj
Date Posted: 17-Jun-2013 at 11:52am
DevForce will automatically add enums found in probe assemblies as known types. By default it should be excluding mscorlib from probing, so I'm not sure why it's trying to add this. If you've cleared or modified the CompositionHost.IgnorePatterns, make sure mscorlib is in this list.


Posted By: gregweb
Date Posted: 18-Jun-2013 at 4:28am
OK, thanks for the data.


Posted By: monikapathak14
Date Posted: 04-Apr-2014 at 3:08am
Am getting the same error while trying to login.
mscorlib exists in ignored patterns' list.

PLease suggest how can i get rid of this??

Here's the code:

 public void Login()
        {
            IsBusy = true;
            IsLoggedIn = false;

            var lc = new LoginCredential(UserName, Password, null);
            _authenticationService.LoginAsync(lc, OnSuccessFullLogin, OnFail);
        }

The code breaks on the last line that's bold and never reaches the OnSuccessFullLogin().
Am using compatibility packs for both devforce and cocktail 2012.

PLease suggest how can i get rid of this??


Posted By: sbelini
Date Posted: 07-Apr-2014 at 11:40am
Where are you setting the ignore patterns list?

It should be in a static constructor in the bootstrapper.




Posted By: monikapathak14
Date Posted: 07-Apr-2014 at 8:35pm
Am setting it in Application_Start event of Global.asax.cs.
Tried setting it in static constructor of bootstrapper but it was still throwing following error.

EmitMapper.MappingConfiguration.MappingOperations.ValueToWrite`1+Actions[T]' cannot be exported as a schema type because it is an open generic type. You can only export a generic type if all its generic parameter types are actual types.

This error was resolved after I added following code to global.asax.cs:

protected void Application_Start(object sender, EventArgs e)
        {                         System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(new IdeaBlade.EntityModel.Web.ServiceVirtualPathProvider());
                      IdeaBlade.Core.Composition.CompositionHost.IgnorePatterns.Add("EmitMapper.*");
        }


So the ignorepatterns problem is resolved. Also, mscorlib is also included by default in the ignorepatterns' list at the above line..if seen at runtime(through debugger).


Please suggest what should be done to avoid following error now:

Type 'System.Diagnostics.Contracts.RuntimeContractsFlags' cannot be added to list of known types since another type 'System.Diagnostics.Contracts.RuntimeContractsFlags' with the same data contract name 'http://schemas.datacontract.org/2004/07/System.Diagnostics.Contracts:RuntimeContractsFlags' is already present.

This occurs at the LoginAsync call as mentioned in earlier post.
Please suggest any breakthrough in this known type error.


Posted By: monikapathak14
Date Posted: 08-Apr-2014 at 3:14am
uploads/2090/DebugLog.zip - DebugLog.zip

Uploading the log file



Print Page | Close Window