Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load type error when running in Max 2016 #1

Open
SimonWEC opened this issue Jun 28, 2016 · 10 comments
Open

Unable to load type error when running in Max 2016 #1

SimonWEC opened this issue Jun 28, 2016 · 10 comments

Comments

@SimonWEC
Copy link

Hi Tim,

Thanks for making NLM3 available.

I am working with your code to allow NLM3 to read NLM2 data. Currently I have it compiling and running on Max2016; the NLM3 window opens the first time but after closing and attempting to open again I get the following error:

Runtime error: dotNet runtime exception: Unable to load type System.Collections.Generic.List'1[[NestedLayerManager.IO.Data.FolderData, NestedLayerManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] required for deserialization.

I think I have almost fixed it, the solution appears to lie in providing a binding class for the BinaryFormatter in: NestedLayerManager.MaxInteractivity.MaxIO.GetAppData() - this has caught the other errors for LayerData and NlmData so It looks like I just have to wrap FolderData in a list to fix the error above. Still puzzled as to why it can't find your IO.Data classes when they're sat in the same assembly that's using them. Of course I am learning C# as I go so it's possible it's me!

All the best
|Simon

Ps

I'm working at Burrows, hence the effort to get NLM3 onto Max2016 since we leverage NLM so much.

@SimonWEC
Copy link
Author

SimonWEC commented Jun 28, 2016

Sorted!!

namespace NestedLayerManager.IO
{
    class DeserialisationBinder:SerializationBinder
    /*  Got this here: http://spazzarama.com/2009/06/25/binary-deserialize-unable-to-find-assembly/ 
    The hope is that this class will solve the 'Unable to load type' deserialisation error. */
    {
        public override Type BindToType(string assemblyName, string typeName)
        {
#if DEBUG
            MaxListener.PrintToListener(assemblyName + " | " + typeName); 
#endif
            Type typeToDeserialise = null;
            string currentAssembly = Assembly.GetExecutingAssembly().FullName;

            //  We are always using this assembly: no! seems to work using the assembly passed to this class
            //assemblyName = currentAssembly;

            //  Example 'Type not found' when error:
            //  System.Collections.Generic.List`1[[NestedLayerManager.IO.Data.FolderData, NestedLayerManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
            //  Get the type using the typeName and assemblyName:
            string type_name_arg = string.Format( "{0}, {1}", typeName, assemblyName );
#if DEBUG
            MaxListener.PrintToListener( "GetType( " + type_name_arg + " )" );  
#endif
            typeToDeserialise = Type.GetType( type_name_arg );

            return typeToDeserialise;
        }
    }
}

Creating this class and then attaching it to the BinaryFormatter() like this:

BinaryFormatter binForm = new BinaryFormatter();
binForm.Binder = new DeserialisationBinder();

fixed the issue and now the NLM3 window opens and closes and retains information. As I said, I'm still learning C# so it's possible I've missed something in VS2012 settings and this was unnecessary!!

|Simon

@EricChadwick
Copy link

Hi Simon,

Are you able/willing to publish updated DLLs for Max 2016?

I would love to use 3 there, and also with your improvements.

Thanks!
Eric

@SimonWEC
Copy link
Author

Hi Eric,

Since we depend on NLM2 in our pipeline but found issues using it in Max2016, it made sense get NLM3 working. I have Tim's current beta 5.0 compiled for Max2016 - it just needed to be done for .NET 4.5.

I'm working on a beta 6.0 version which can read / write NLM2 data (for obvious legacy reasons), as well as adding some other functionality users expect from NLM2.

We've already discussed the possibility here, of adding a branch to the NLM3 repository to make this available but of course this is Tim's baby so I need to contact him ( or if you get this Tim, could you let me know what you think?).

I don't have a problem with uploading the .dll files if that's ok with the author.

All the best
|Simon

@Morph-3dv
Copy link

Hi Simon and Eric,
Im also interested in having NLM 3 on 2016, please see if you can share the wonderful work you guys have done.

@timhawker
Copy link
Owner

Hey Simon. Thanks for finding and fixing the problem, great work!

We've already discussed the possibility here, of adding a branch to the NLM3 repository to make this available but of course this is Tim's baby so I need to contact him ( or if you get this Tim, could you let me know what you think?).

I would love for you to upload any changes you make. Sounds like others would be very happy to receive the updates, too :)

Cheers
Tim

@EricChadwick
Copy link

Simon, any updates on this?

I'm using 3ds Max 2016 more and more these days, and would love to use NLM3 there.

@SimonWEC
Copy link
Author

SimonWEC commented Sep 22, 2016

Hi Eric,

There shouldn't be any difficulty, but since I've been coding this on work time, I'm just waiting for the OK from work to upload it.

|Simon

@EricChadwick
Copy link

Tim has given his OK. Maybe you're waiting for your workplace to give you the OK?

@Morph-3dv
Copy link

Bump
I Desperately need this script!

@EricChadwick
Copy link

@SimonWEC Any updates on this? I don't desperately need it, but it sounds like it might be a nice step up from the scripted version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants