-
Notifications
You must be signed in to change notification settings - Fork 224
Accessing resources from non-DNX assembly Cause Exception System.IO.FileNotFoundException #3047
Comments
This is a very important issue, since it prevents to use very popular libraries, like Entity Framework 6 from DNX projects, when current thread culture is other than invariant culture. |
Is there any update on this issue? Will there be a fix for this issue in RC1? Thank you! |
This issue is still unresolved on RC1. This problem basically prevents you from using Any chance this issue could get a higher priority? |
This is an extremely important issue for us as it prevents us from using non-dnx libraries that we've spent several years creating. Please don't let this one go unfixed. |
Thought that RC means Release Candidate, meaning it is considered to be soon released and that developer can start implementing solutions. |
Folks, DNX is being retired in the next release i.e. we won't be releasing another version of DNX with ASP.NET Core. The new command line experience will be through dotnet CLI (https://github.com/dotnet/cli). I recommend trying it out. |
Any plans on fixing this? It is not fixed in latest RC2 too. I dont get it how such a serious stuff can be around for so long time without a fix. |
It means there's other more serious stuff to get to first. As @muratg said, DNX is being retired and we're busy working on making the dotnet CLI command line tools work for the basic flow (dev, test, debug, publish). Once the basics work, then we'll get to xproj -> csproj integration again, once that works, then we'll handle xproj -> csproj with resources. |
Ok, that I understand. What I don't understand is that MS gave ASP.NET 5 a "Go Live" license for a production deployment even with such a drawbacks? Very strange. Any possible workarounds? |
Not that I'm aware of, it probably requires some horrific code. |
Is this related only to some specific function, which can be removed/avoided? "Leak" mentioned above that it prevent from using Localization. I have removed any localization from our code and still having the same error while calling 3rd party library function. In other words - is there ANYTHING I can do to get rid of this error while still using the 3rd party library, which is essential for our project? Please, do not answer that there is nothing I can do. |
This issue is specifically to do with using resource from a csproj project reference. Is that your scenario? Nobody has dug into a workaround because most if the infrastructure is changing and the issue will fix itself when we move to the cli. As for a workaround, if you can provide a sample I'll see if I can figure something out. I'm assuming you're using rc1 bits right? |
@davidfowl, this issue appears to be caused by referencing assemblies created from csproj projects. We need to be able to reference those assemblies, of course, because they represent years of research and development and they do and will support both future asp.net projects as well as console apps, windows apps, etc. If you're saying that this will be resolved prior to release of asp.net 5 mvc 6, then I think that's fine. If not, then it needs to be addressed prior to release. @chosenek, there is a workaround, but it requires you to rebuild the older project with a slight modification to the auto-generated resource files. I don't have that on-hand right at the moment. I'll look it up tomorrow and post here, referencing the author of that workaround. Essentially, the workaround is to load the assembly and pass GetName() for the assembly name containing the resources. By default, I believe the auto-generated code passes the name of the currently executing assembly, which is what fails. Amended: @davidfowl - those are not project references, of course, they are direct references to the assemblies. |
@davidfowl I am on the same line as chosenek regarding the "GoLive" license. I mean it is labled as "Release Candidate" which means according to Wikipedia that the product has the potential to be the final product if no serious bugs emerge. This does not really fit together with removing dnx and replacing it with cli which is kind of a huge design change late in the cycle... I'm sure there are a ton of good reasons for all this. But having started to use RC1 for two weeks now, I ran into several problems that hinder to see it as a "Go Live" product. |
@davidfowl I am not sure if the example will help here, but we are using an Interactive Inteligence (call center stuff) and I am stuck at the very beginning while establishing connection with server. David, let me ask differently. We have been planning on using ASP.NET 5 for upcoming, bigger, project. I have convinced everyone that this is a way to go. Now with these changes planned - do you think its better idea to avoid ASP.NET 5 until final version is out? We are still at the stage where change is possible. @mightyzot An example would definitely help. But if you mean by the 'older project', the assembly which causing this issue, then I am afraid we don't have a access to the source code. Its 3rd party application. What I have also noticed is that while referencing required assemblies in non asp.net 5 projects, all assemblies which are dependency to the referenced ones are copied to the project output automatically. In asp.net 5, I have to add all of them one by one as a direct reference in the project. Everyone: Isn't there a way to use a reflection to instantiate the assembly or just call the method of the assembly that causing the problem, with some reflection-like tweaks? |
This issue is not limited to surfacing when attempting to load/use resources in an embedded assembly from a csproj project reference. I have a solid repro for this when referencing an already-built DLL containing an embedded resource.
So is it the case that all ISV's and 3rd party vendors will need to change the way their products get built simply in order for their customers to be able to reference their assemblies? I'm almost certainly misunderstanding something here, any clarification would be appreciated. I've confirmed the issue on CRL RC1 Update 1 and on 1.0.0-rc2-16357 in a simple console app referencing the assemblies, which were built against .NET 4.5 using the "traditional" project/build system |
There is a workaround posted in But it does require access/modification to the Resources.Designer.cs |
@crokusek, Resources.Designer.cs will be rewritten by Visual Studio the moment you edit any resource item. So this workaround will only work when you stop maintaining your resources, or when you constantly roll back any change VS makes to that particular line. It's a highly brittle workaround until the CLI team fixes the assembly resolution problems for the venerable ResourceManager class. @davidfowl, you mentioned
There are several issues open on this bug, and they all point back to this one, but no indication whatsoever whether this is even being investigated. And since this showstopper is labelled as Backlog (as is https://github.com/dotnet/cli/issues/550), I can only assume it will not be fixed for v1; but I'd love to be corrected. |
A better workaround--its reflection man to the rescue!!. Usage (e.g. place in Startup.cs):
|
We have made a mistake and adopted Asp.Net Core earlier than we should, the go live license deceived us. The go live seems to be for a Hello World apps only. You've promised us the moon guys and here we are. |
@musabsudan We upgraded from Beta7 to RC2 (since Beta8+ didn't work), and it works just fine with EF6 migrations in a csproj-project. I also tried adding a custom resource file to the csproj-project, and that is also accessible from the .Net Core project. So we're not seeing any problems with this right now. What's the use-case that doesn't work for you? |
The problem was with consuming resources in libraries that were built for other projects, libraries that have been in production and likely couldn’t be recompiled. Adding resources directly to the project was not an issue (in case that is how you tested this.) From: patrikwlund [mailto:notifications@github.com] @musabsudan https://github.com/musabsudan We upgraded from Beta7 to RC2 (since Beta8+ didn't work), and it works just fine with EF6 migrations in a csproj-project. I also tried adding a custom resource file to the csproj-project, and that is also accessible from the .Net Core project. So we're not seeing any problems with this right now. What's the use-case that doesn't work for you? — |
@patrikwlund I have been redirected to here from other places, my main issue was in the localization and the use of resource files. Globalization and localization
No worries I already decided to stop any serious development with Asp.Net Core till you guys figure the basic workflow and decide on something. But today one of my team members asked for help. |
Moving aspnet/Localization#123 From @luchen1021 to this repo
Beta 8 load resource assembly cause exception System.IO.FileNotFoundException. The resource assembly is defined in legacy .NET class library, not DNX class library. The same solution works for Beta 7 but fails when using Beta 8.
Beta 8 Solution
https://github.com/luchen1021/AspNet5Beta8Resource.git
https://github.com/luchen1021/AspNet5Beta8Resource
Beta 7 Solution
https://github.com/luchen1021/AspNet5Beta7Resource.git
https://github.com/luchen1021/AspNet5Beta7Resource
Change project reference to binary reference for Legacy Library and Legacy Resource Library.
https://github.com/luchen1021/AspNet5Beta8ResourceBinaryReference.git
https://github.com/luchen1021/AspNet5Beta8ResourceBinaryReference
Running in Visual Studio 2015 with IISExpress still get the same exception as shown in top comment.
Publish works fine in binary reference approach. After deploying the published output to IIS (not IIS express), it works fine without any exception.
Exception Detail:
System.IO.FileNotFoundException: {"Could not find file 'AspNet5Beta8Resource.LegacyResources.resources'.":null}
Data: {System.Collections.ListDictionaryInternal}
FileName: null
FusionLog: null
HResult: -2147024894
HelpLink: null
IPForWatsonBuckets: {1858045768}
InnerException: null
IsTransient: false
Message: "Could not find file 'AspNet5Beta8Resource.LegacyResources.resources'."
RemoteStackTrace: null
Source: "mscorlib"
StackTrace: " at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at AspNet5Beta8Resource.LegacyResources.Properties.Resources.get_Title() in D:\Project\GitHub\AspNe
t5Beta8Resource\AspNet5Beta8Resource.LegacyResources\Properties\Resources.Designer.cs:line 68
at AspNet5Beta8Resource.LegacyLibrary.LegacyClass.GetTitle() in D:\Project\GitHub\AspNet5Beta8Resource\AspNet5Beta8Resource.LegacyLibrary\LegacyClass.cs:line 14
at AspNet5Beta8Resource.DnxWebHost.Controllers.ValuesController.Get() in D:\Project\GitHub\AspNet5Beta8Resource\AspNet5Beta8Resource.DnxWebHost\Controllers\ValuesController.cs:line 21"
TargetSite: {System.Reflection.RuntimeAssembly InternalGetSatelliteAssembly(System.String, System.Globalization.CultureInfo, System.Version, Boolean, System.Threading.StackCrawlMark ByRef)}
WatsonBuckets: null
_HResult: -2147024894
_className: null
_data: {System.Collections.ListDictionaryInternal}
_dynamicMethods: null
_exceptionMethod: {System.Reflection.RuntimeAssembly InternalGetSatelliteAssembly(System.String, System.Globalization.CultureInfo, System.Version, Boolean, System.Threading.StackCrawlMark ByRef)}
_exceptionMethodString: null
_fileName: null
_fusionLog: null
_helpURL: null
_innerException: null
_ipForWatsonBuckets: {1858045768}
_maybeFullPath: null
_message: "Could not find file 'AspNet5Beta8Resource.LegacyResources.resources'."
_remoteStackIndex: 0
_remoteStackTraceString: null
_safeSerializationManager: {System.Runtime.Serialization.SafeSerializationManager}
_source: "mscorlib"
_stackTrace: {sbyte[192]}
_stackTraceString: null
_watsonBuckets: null
_xcode: -532462766
_xptrs: {0}
The text was updated successfully, but these errors were encountered: