dongfo / autofac

Automatically exported from code.google.com/p/autofac
0 stars 0 forks source link

Portable build warnings in a Metro style app #358

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I downloaded 
http://code.google.com/p/autofac/downloads/detail?name=Autofac-2.6.1.841-Portabl
e.zip and tried using it in a C# Metro style app. 

The build resulted in 2 errors I don't know how to get rid off:

1. Reference to type 'System.Reflection.BindingFlags' claims it is defined in 
'c:\Program Files (x86)\Reference 
Assemblies\Microsoft\Framework\.NETCore\v4.5\mscorlib.dll', but it could not be 
found

2. The assembly "Autofac.dll" does not have a NeutralResourcesLanguageAttribute 
on it. To be used in an AppX package, portable libraries must define a 
NeutralResourcesLanguageAttribute on their main assembly (ie, the one 
containing code, not a satellite assembly).

I wanted to take a look at the source code and try to fix the issues, but 
couldn't find it while browsing the repository. Where is it committed to?

Are there any plans to make the portable build work with Metro style apps?

Original issue reported on code.google.com by damir....@gmail.com on 7 Apr 2012 at 2:06

GoogleCodeExporter commented 8 years ago
Thanks for the report. These warnings shouldn't prevent use of the library. We 
need to add the mentioned attribute (2) so that Autofac's exception message 
strings are packaged correctly into AppX.

Regarding the BindingFlags warning - are you using any of the 
methods/constructors that accept BindingFlags? It appears that 
BindingFlagsConstructorInvoker would be the type causing this. In this 
instance, I think we need to expose different constructor parameters (e.g. 
"bool usePrivate") as a substitute when running with Metro style apps, and 
remove the BindingFlags versions from Autofac's public portable API surface.

Original comment by nicholas...@gmail.com on 12 Apr 2012 at 5:45

GoogleCodeExporter commented 8 years ago
You're right. In spite of the warnings (not errors as I've written above) I can 
use the library and it works. But I am a bit concerned about the store 
certification process, although the Windows App Certification Kit currently 
doesn't seem to complain about it.

I'm not using any method or constructors accepting BindingFlags, at least not 
that I'm aware of. These are the only APIs that I'm currently calling:
var builder = new ContainerBuilder();
builder.RegisterType<MyViewModel1>().SingleInstance();
builder.RegisterType<MyViewModel2>();
builder.RegisterType<MyService>().As<IMyService>();
var container = builder.Build();
container.Resolve<MyViewModel1>();

Original comment by damir....@gmail.com on 14 Apr 2012 at 10:34

GoogleCodeExporter commented 8 years ago
It doesn't fix it for the current release... but I've added 
NeutralResourcesLanguageAttribute to every assembly in the 3.0 branch.

Original comment by travis.illig on 14 May 2012 at 6:26

GoogleCodeExporter commented 8 years ago
Hi Travis / Nick,
We're using Autofac (2.6.1) with a new metro app for a client.
When autofac throws an error it tries to read the exception message from a 
resource and crashes with a MissingManifestResourceException (Unable to load 
resources for resource file). Is this related to this NeutralResourcesLanguage 
attribute missing, or would you like a separate issue to be raised?

If the fix is just the change to the attribute, would you please consider 
backporting this fix to 2.x while 3.0 is not yet ready for use?

Original comment by jos...@joshka.net on 18 Jun 2012 at 1:59

GoogleCodeExporter commented 8 years ago
Thanks for the additional info. Not sure if this is related or not. We'll 
definitely get this running in the 2.x branch, 3.x is still some time off. 
Cheers!

Original comment by nicholas...@gmail.com on 18 Jun 2012 at 2:27

GoogleCodeExporter commented 8 years ago
Hey Nick,
I'll raise a proper issue for the error that we're hitting with our metro app.

Original comment by jos...@joshka.net on 24 Jun 2012 at 2:18

GoogleCodeExporter commented 8 years ago
The BindingFlags issue also breaks Code Analysis on the project.

2>  Running Code Analysis...
2>MSBUILD : error : CA0055 : Could not load Project.exe. The following error 
was encountered while reading module 'Autofac': Could not resolve type 
reference: [mscorlib, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089]System.Reflection.BindingFlags.
2>MSBUILD : error : CA0052 : No targets were selected.

Original comment by kjetil.l...@gmail.com on 14 Sep 2012 at 9:03

GoogleCodeExporter commented 8 years ago
The 3.0 branch has been moved to trunk and should be released soon. We have 
tested use on a simple Windows Store app and the BindingFlags warning is gone.

You may still see some SecAnnotate.exe or FxCop issues, but these are Portable 
Class Library problems, not something we can fix. See this StackOverflow 
question for an example:
http://stackoverflow.com/questions/12360534/how-can-i-successfully-run-secannota
te-exe-on-a-library-that-depends-on-a-portab

I'm going to close this as fixed since it's set for the impending 3.0 release. 
Once you get 3.0, let us know if you find anything else and we'll hook you up.

Original comment by travis.illig on 20 Sep 2012 at 4:17