New Posts New Posts RSS Feed: Type cannot be added to list of known types
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Type cannot be added to list of known types

 Post Reply Post Reply
Author
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Topic: Type cannot be added to list of known types
    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

Edited by gregweb - 15-Jun-2013 at 5:25am
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
gregweb View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 10-Sep-2009
Location: Clearwater, Fl
Posts: 253
Post Options Post Options   Quote gregweb Quote  Post ReplyReply Direct Link To This Post Posted: 18-Jun-2013 at 4:28am
OK, thanks for the data.
Back to Top
monikapathak14 View Drop Down
Newbie
Newbie


Joined: 26-Jun-2013
Location: Gurgaon
Posts: 10
Post Options Post Options   Quote monikapathak14 Quote  Post ReplyReply Direct Link To This Post 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??
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post 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.


Back to Top
monikapathak14 View Drop Down
Newbie
Newbie


Joined: 26-Jun-2013
Location: Gurgaon
Posts: 10
Post Options Post Options   Quote monikapathak14 Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
monikapathak14 View Drop Down
Newbie
Newbie


Joined: 26-Jun-2013
Location: Gurgaon
Posts: 10
Post Options Post Options   Quote monikapathak14 Quote  Post ReplyReply Direct Link To This Post Posted: 08-Apr-2014 at 3:14am
DebugLog.zip

Uploading the log file
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down