Wednesday, February 10, 2010 7:35 AMI created a new project targeting .NET CF 3.5. In the project I add a .xmta file and in the default form1 I create a function that returns a type of SqlCeConnection. This is literally all I did with the new project. When I try to build i get this error:
Error 1 genasm.exe(1) : error There was an error initializing NETCF35_Testbench.Form1.foo. Could not load file or assembly 'System.Data, Version=220.127.116.11, Culture=neutral, PublicKeyToken=969db8053d3322ac, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified. NETCF35_Testbench
Looking at the project references it is clear that all dlls referenced are for 3.5. Does anyone have a suggestion? Is there a way to tell genasm.exe where to look for the System.Data dll? Using VS 2008, Windows 7.
Thanks in advance.
N I C K
Wednesday, February 10, 2010 3:37 PMUpdate with more info:
The error appears to occur as a direct result of exposing a type from the SqlServerCE or SqlClient namespace. The simple existence of this method in the default form1 causes the genasm.exe error to appear. If I remove the method or ensure both return type and parameters are not in the SqlServerCe namespace (or the SqlClient namespace) then all is well.
Imports System.Data Public Class Form1 Public Function foo(ByVal c As SqlServerCe.SqlCeConnection) As Object Return Nothing End Function End ClassAs does this:
Imports System.Data Public Class Form1 Public Function foo() As SqlServerCe.SqlCeConnection Return Nothing End Function End ClassIf I change the exposed type to something in the SqlClient namespace (such as SqlConnection) then I get a similar but slightly different genasm.exe error:
Error 1 genasm.exe(1) : error There was an error initializing NETCF35_Testbench.Form1.foo. Could not load file or assembly 'System , Version=18.104.22.168, Culture=neutral, PublicKeyToken=969db8053d3322ac, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified. NETCF35_Testbench
Note that now it complains about not finding assembly "System" instead of "System.Data".
N I C K
Friday, February 12, 2010 9:07 PMHiCan you try setting the build action of the xmta file to "content" ?
Monday, February 15, 2010 6:59 PMThanks for the reply. Setting the build action to "content" for the xmta file allows the program to build but the asmmeta assembly is not generated therefore making the form designer useless for subclassed forms and controls. You could do this if you can isolate the code causing the problem and disable it, build the asmmeta assembly, and then set the action to "content". You don't need to rebuild the asmmeta assembly unless you add a new subclassed form or control type and you want to use the designer with it.
It turns out this is a known bug: https://connect.microsoft.com/VisualStudio/feedback/details/339763/genasm-exe-fails?wa=wsignin1.0
The workaround presented didn't work for me but it sounds like the issue will be fixed in VS 2010 so I will wait until then to try to upgrade some old projects.
N I C K
Friday, December 30, 2011 5:21 PM
I had a similar issue with some methods in a class. I had a method that received a parameter of type SqlCeConnection. This is what I tried.
1. I changed the type of the parameter to object and then casted the parameter inside the method. That worked.
2. Then I had another method with the same problem. I changed the public modifier to internal and that also worked.
I hope that helps.
Marcelo Hernán Ruiz
Monday, January 09, 2012 4:15 PM
Ya this works if you can refactor the code in such a way, but i've found an easier work around. This is cut and pasted from a different post of mine, so that is why it sounds weird:
The ONLY way I've found around this is to have a separate project for designing your forms. Add forms to this project from your main project, and add them as LINKS. Take your non-designer form code and move it into a compiler switch so that your code will not be compiled int he designer project. Then you can lay out the forms in the designer project, then write code to drive them in your main project. The designer project should only compile the minimum needed to support your layout, or you risk Genasm errors. Since doing this approach my life has been a lot easier.
N I C K