Forms don't load after upgrading to .NET Framework 4.0
-
10 มีนาคม 2555 2:08
I have upgraded a solution with several projects inside from VS2005 to VS2010, and because of a dependency issue I updated all projects to target .NET Framework 4.0. One of the VB projects now doesn't load two of its forms. I got an error:
Error 54 Invalid Resx file. Could not load file or assembly 'DependentVBProject, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. Line 136, position 5. Path\file1.resx 136
Error 55 Invalid Resx file. Could not load file or assembly 'DependentVBProject, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. Line 133, position 5. Path\file2.resx 133Another form loads perfectly. The DependentVBProject builds fine, and is set as a dependency for the startup project.
Before upgrading to .NET Framework 4.0, this project loaded fine, but something else that had it as a dependency did not build (because of other 4.0 dependency).
I don't know what to do to make it work... Please help !
ตอบทั้งหมด
-
10 มีนาคม 2555 2:44
-
10 มีนาคม 2555 7:49
Thank you, I suspected something like that - but I don't know where to look to check. I have tried everything I could think of. I need the project to build both in x64 and Win32. I think I am building the dependent dll for the same platform as the main project though - either 64 or 32. In the same solution, Configuration Manager shows that every project in the solution is building in Debug x64 (or they are all building in Release x64/ or all building in Debug win32 - I checked). Is there any way to verify that the dependent dll (in x64/Debug or x64/Release) is 32 or 64 bit ? Is there any way to get access to the form settings - perhaps it does not find the new dll and I can modify the properties ? right now the form is not loading at all, all I am getting is an error.
In the Compile - Advanced all projects target .net framework 4.0. (is that the build target you are referring to ?)
-
10 มีนาคม 2555 12:46
-
10 มีนาคม 2555 13:07
Hello,
Have you tried cleaning the solution, verify that the binaries (DLL and EXE) does not exists followed by rebuilding the solution. Another option, create a new project DependentVBProject1 that replaces DependentVBProject that mirrors the first one then in the main project remove the reference to DependentVBProject and add in DependentVBProject1, rebuild. What are the results of the solution rebuild?
KSG
-
12 มีนาคม 2555 6:33
It is very puzzling. Even after re-building, I can build in Win32, but not in x64. I must be doing something wrong, because even though I made the project to target 2.0, it refuses to load its dependencies (which I also made to target 2.0). I wish I could roll back to the time when I was able to build it (though now I start to think that maybe it never did build on vs2010 in x64, I must have only tested Win32 ?). I don't know what to do...
[Until I added all the dependencies, even with the rebuilt solution, there was no way to tell if it was going to work. These forms have controls that use classes from the dependent projects. ]
So I can build and run in Win32 and not in x64. If I try either Debug or Release, I get a linker error saying that it can't find my 3 dependent projects.
And just for check, other projects that use these 3 projects, do build in x64.
-
12 มีนาคม 2555 7:10
Correction: project does build in Win32, but I still get an error when I try to load two of its forms. The only thing I can do (instead of viewing the Designer.vb) is Show Call Stack, that shows me a list of errors starting with
at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
and basically I understand that it still can't load the dependent dlls. Oddly enough, after a successful build (that happens randomly, not every time in Win32), I can run it - but it doesn't have all it needs on the form and it crashes.
This behavior makes absolutely no sense...
If you can help, I'll e-mail you chocolate...
-
13 มีนาคม 2555 5:26ผู้ดูแล
Hi emptyheaded,
Welcome to the MSDN forum.
Here is my suggestion, you can have a try.
Delete the Obj and Debug folder under the application folder. And try to compile the dependent VB project firstly. And then compile the whole application.
If the issue doesn’t cover, I afraid that there is some issue in your code. Some assembly supported by VS2005 may be changed in VS2010. So you can try to check which assembly caused the issue and edit your code.
Hope it helps.
Mark Liu-lxf [MSFT]
MSDN Community Support | Feedback to us
-
13 มีนาคม 2555 19:44
I have deleted Obj and Debug, I have compiled the dependent project first. Somehow, the project can't find my dependent dll. It is puzzling, because it is not a version issue, it is a dependency issue. Right now I have added in the project a Reference:
<Reference Include="dependentDll">
<HintPath>
some_path\output\$(Platform)\$(Configuration)\dependentDLL.dll
</HintPath>
</Reference>I copied the path from the Release folder where the dll is located. During build, I have the message:
Primary reference "dependentDLL".
18>c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "dependentDll". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
18> For SearchPath "{HintPathFromItem}".
18> Considered "
18> some_path\output\x64\Release\dependentDll.dll
18> ", but it didn't exist.So i'm looking at the path in the build error, identical to the one in Windows explorer where my dll is. (please ignore my replacing the actual path with some_path). What is going on ? If I can resolve this problem, then all the variables that build my form will be defined and the form will build.
[Any other way to specify where input projects are located doesn't seem to work nor give me visible errors - except for the fact that the forms don't build; I have included all the projects as dependencies - in the same solution, with check marks to show dependency - and it doesn't seem to help locating necessary resources, the project does seem to pass the "build" with lots of warnings but no errors but the forms don't show, there are errors instead of the form layout, and the errors point to missing parents of the objects on the forms - parents that are located in one of the dependent projects. The project does load in VS2005 - but there must be some configuration that I can't see somewhere. ]
-
13 มีนาคม 2555 23:09
-
15 มีนาคม 2555 3:33ผู้ดูแล
Hi,
Any update? I think Armin's suggestion to use fusion log viewer is very helpful to troubleshot this kind of issues.
If you need any further assistance, please feel free to let me know.
Good day!
Michael Sun [MSFT]
MSDN Community Support | Feedback to us
-
16 มีนาคม 2555 18:20I looked at the logs but didn't find any information I could use. The only update: my project builds and runs with the AnyCPU setting (if I try to look at the forms though, it gives me the error again and doesn't rebuild until I delete the output folder). Can't figure it out. I looked at forums on the web, and the one other thing that I have seen with similar types of errors was related to IIS - which I am not using. If anyone can have any idea, please let me know !
-
16 มีนาคม 2555 23:01
Just to be sure...:
FUSLOGVW must be started as Administrator. Otherwise you can't enable logging. Click the "settings..." button to "Log bind failures to disk". Try again to reproduce the problem you have, then click the Refresh button in FUSLOGVW. No log entries?
Armin
-
17 มีนาคม 2555 1:09
I had log entries - I just didn't know what to do with them. I am looking at the log - I just can't figure out what it is telling me; It appears that it can't find one of the dependent dlls (probably the first one it is looking for) - and I can't even see an error about it not being found in the default output directory (they all have the same output directory). I have checked and in the default directory there are all the dlls the app needs.
The entry that says
Attempting download of new URL file:///c:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/a_dot_net_dependent.DLL.
and about 20 more make no sense - why would it look somewhere else for the dll and not in its default location ?
The operation failed. Bind result: hr = 0x80070002. The system cannot find the file specified. Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under executable c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
.....
LOG: This bind starts in default load context. LOG: Using application configuration file: c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///c:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/a_dot_net_dependent.DLL.
....
-
17 มีนาคม 2555 1:13
And the "Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind)." worries me but I don't know what to do about it - or even if I should worry or that's just something normal ?
-
17 มีนาคม 2555 10:57
What is "a_dot_net_dependent.DLL"?? That's the real name from the log? It's important because it's the one we are looking for. As it's part of the IDE, I don't know why you don't post the real name (if it isn't the real name).
Try reparing VS installation (as administrator).
Armin
-
17 มีนาคม 2555 11:56What is your target? Check in your project >> properties and check target frame work of you dll.
-
17 มีนาคม 2555 19:54
Target: 4.0
The dot_net_dependent_dll in this case is NewCoordinates.dll (and I didn't think its name is important).
I will try to repair VS, or even do a fresh install. -
19 มีนาคม 2555 2:06ผู้ดูแล
Hi,
I am looking forward to your update. If the issue still occurs after you repair VS, please feel free to let me know.
Have a nice day!
Thanks
Michael Sun [MSFT]
MSDN Community Support | Feedback to us
-
27 มีนาคม 2555 20:35
I have re-installed VS - and Windows (to clean any registry entries left by some install). I knew re-installing doesn't help with this problem, since one project doesn't work but several hundreds do...
I have re-built the project from scratch. After re-setting all its properties to make sure that every item targets .NET Framework 4, x64 CPU, and had to fix the Resources.Designer.vb, the project doesn't run in x64, and I am back to the errors about the resx files.
For more details: the project has two forms and one UserControl. The UserControl only shows up in the Toolbox in x86, it doesn't show up in Toolbox in x64. So... The problem must be with the UserControl... Still, while I was building the new project, I was able to execute a new form created with the UserControl in x64 - sometimes.
So up to this point, I believe there is something in the c++ files that the UserControl depends on that requires build under Win32, even though the dll containing them is built with x64 and DependencyWalker seems to think the dll is good.
Thank you for your help... I will still try to get this solved because even though I can build this most of the time with the rebuilt project, there is a chance that it may fail sometimes (I don't understand this unpredictable behavior, this is what bothers me most).
- แก้ไขโดย emptyheaded 27 มีนาคม 2555 20:55
-
28 มีนาคม 2555 1:43ผู้ดูแล
Hi,
Thanks for the update! I would say that we generally troubleshot such problems by the fusion log viewer and another very useful tool -- Dependency Walker, http://www.dependencywalker.com/. Could you please try Dependency Walker to get some hint of the problem?
Good day!
Thanks
Michael Sun [MSFT]
MSDN Community Support | Feedback to us
-
30 มีนาคม 2555 19:19
I have used DependencyWalker on the dependencies from the beginning, and they are good. I also used a program called CheckAsm to verify dotNet dlls and they seemed good. But I figured out where my problem is now: One of the projects that is used as a dependency and does nothing but builds controls, seemed so inoffensive and checks out - and gave me no errors. Still, when I tried to add one of its controls in a blank form, it gave me the same type of error that the control from the current project did - and I got an error saying that the control is not available and will be removed from the toolbox.
So now I am trying to figure out why that project, and every other vb.net project, with no dependency, if it has to make a control, it builds incorrectly in x64. When I was trying to learn what is with these UserControls, I started reading a book and downloaded its online code. It ran, it was great - until just now when I tried to test it in x64 and - it failed ! Errors when I try to look at the form:
Could not find type 'Chap15SampleCode.ListSelector'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.
The variable 'ListSelector1' is either undeclared or was never assigned.I also get warnings, not sure what to do about them:
Possible problem detected while building assembly 'Chap15SampleCode': Referenced assembly 'mscorlib.dll' targets a different processor
Possible problem detected while building assembly 'Chap15SampleCode': Referenced assembly 'System.Data.dll' targets a different processorI checked and found System.Data as a Reference is in c:\Windows\Microsoft.NET\Framework... (if I change the target framework to 4.0 the Reference is in c:\ProgramFiles(x86)... that was what my project had and I tried to change it, I couldn't, I had a few others in ProgramFiles(x86) and I thought that may be the problem ?)
Reinstalled VS2010, reinstalled Windows - the errors were the same before btw - but I do have a clean system so I can't blame it.
If I can get this simple project to work, I hope the real projects will be easy - and that will be the solution to all my problems.- Please help me figure out what this is about. Thank you.
- แก้ไขโดย emptyheaded 30 มีนาคม 2555 19:27
-
30 มีนาคม 2555 19:46
Since seeing Chap15SampleCode leads me to believe you are working with code from a book. If so I would contact the book author and tell him or her what you are having issues with (direct them to this forum post) and see what they suggest.
Here is a thought, close the current solution in Visual Studio, create a brand new project. Remove the form from the new project. Next add in each form, code module and class modules from the problem project into the newly created project. Build the new solution, my guess is that it will be missing one or more project i.e. Chap15SampleCode.ListSelector (guessing this is depentant project), add them in one by one and build the newly added project. If when building the newly added project you get errors as you are current getting you might need to create a blank project for any dependent project as you did for the main project.
One thing I am fairly sure of is the problem is not Visual Studio or Windows.
KSG
-
30 มีนาคม 2555 20:13Do you have the source code of the dll or did you reference a precompiled assembly? If that assemlby targets x86, it won't work in a AnyCPU process on a x64 platform.
Armin
-
30 มีนาคม 2555 20:15
I found out what this is about ! I had to set the TargetCPU to AnyCPU and then I can build under x64 (huh ? but yes, it does make sense to allow the program to choose the processor mode at run/build time).
Thank you very much for all the help !
- ทำเครื่องหมายเป็นคำตอบโดย emptyheaded 30 มีนาคม 2555 20:16