Giving a strong name to Mogre

Kodachi_Garou

20-02-2008 14:58:17

Hi all,

This is a feature request that many may find unnecessary, but which I would think would greatly benefit Mogre in the long run and costs virtually nothing.

As some .NET users will recognize, it is quite common to sign managed assemblies with a strong name key. This allows for the assembly to be registered in the global assembly cache and also provides some modicum of security over the contents of the assembly.

These issues are not so important to Mogre community, but there is another very practical reason that Mogre should be given a strong name. Many of the new Microsoft tools like Windows Workflow Foundation or DSL Tools support customization with types coming from external assemblies, but unfortunately, due to the nature of those frameworks, require that these external assemblies be signed with strong name keys.

The effort required to implement this is minimal: just generate a new strong name key and check the project option to sign the assembly. I think that in the long run this would benefit Mogre for users wishing to integrate it with the new Microsoft tools.

Best regards,

Gonçalo

raygeee

22-02-2008 08:28:22

I support your request. This would be a good benefit for the next release.

Kodachi_Garou

04-03-2008 15:12:06

Anyone else thinks this is a good idea?

Kodachi_Garou

05-03-2008 22:24:34

Since no one else answered and I needed it for my project, I just went ahead and gave Mogre a strong name :)

It works, but there are some important points that need to be done for both compilation AND running Mogre to succeed without errors or exceptions.

Here's a small step guide to signing Mogre, should anyone need it or the maintainers decide it's worth it:

1. Generate a strong name key pair (using sn.exe or other VS-based means)

2. Compile OgreMain with LINK_TO_MOGRE 0 and sign it with the generated key pair.

3. Go to the Mogre project's AssemblyInfo.cpp and find the following lines:

[assembly:InternalsVisibleTo("OgreMain")];
[assembly:InternalsVisibleTo("OgreMain_d")];

When using the InternalsVisibleToAttribute with strong-name assemblies, both the Source AND Target assemblies must be strongly signed, and the Attribute string itself should include the common PublicKey, as described in http://msdn2.microsoft.com/en-us/library/ms177208.aspx.

The PublicKey string itself can be obtained by running the following command on the OgreMain DLL:

sn -Tp OgreMain.dll (respectively for debug DLL)

This will print a very long PublicKey along with a shortest PublicKeyToken. What we want is the PublicKey and not just the Token. So copy it entirely and change the Attributes to look something like this:

[assembly:InternalsVisibleTo("OgreMain, PublicKey=00240000048(etc...)")];
[assembly:InternalsVisibleTo("OgreMain_d, PublicKey=00240000048(etc...)")];

4. Compile Mogre project, signing it also with the SAME generated key pair.

5. Recompile OgreMain with LINK_TO_MOGRE 1 and don't forget to keep the same signature.

After all these steps, everything should be ok with your strong named Mogre :D

Now if the maintainers feel like it, I think it would be a wonderful upgrade for Mogre.

Best regards,

Gonçalo

Marioko

07-03-2008 13:41:52

if you want strong name take a look to AutoWrapper code, it have a method for setting Mogre namespace...

qi-an

01-09-2008 08:58:36

Hi ,everybody!
Now,I need Mogre that be gave strong name in my project,so I compile the Mogre source according to the tutorial in the wiki.But I failed,I get lots of error ,about like this:

error LNK2001: 无法解æž

Bekas

04-09-2008 15:10:16

@qi-an:
What exactly are the steps that you followed, and at what point are the errors occuring ?
Are the errors when trying to compile native Ogre ?

qi-an

23-09-2008 02:58:34

Bekas,Thank you to pay close attention to my problem,now,The problem has be solved! :D