Strange Exception when using Entity Framework with SQLCE - c#-4.0

I have used before EF 4 and SQLCE with no such problem.
While I have my assembly containing the edmx file and the context self tracking template and in another assembly the self tracking entities, I keep this strange compile error but the project compiles successfully...
Error 1 Error 175: The specified store provider cannot be found in the configuration, or is not valid.
This just dont go away....but the program runs.
Any idea?

Take a look at this question. Hope this helps.

Related

Strange link error - LNK1224: Invalid Image Base

I'm having some real difficulties porting a really old Visual Studio 97 C++ project to Visual Studio 2010. Let me begin by first giving a little background on the errors I was getting immediately prior to this new LNK1224 error because they may be related, but I'm not sure.
Prior to my new error I was receiving this error:
error LNK2005: "void __cdecl operator delete(void *)" (??3#YAXPAX#Z) already defined in LIBCMT.lib(delete.obj) nafxcw.lib(afxmem.obj)
Through some digging I found that the reason for this error was because both the MFC and CRT libraries contain definitions for "new" and "delete" so they were colliding. Microsoft provides 2 solutions for this detailed in http://support.microsoft.com/kb/q148652/ . One of them was to make sure that in all your files you always include the MFC headers (afx stuff) first. Well there are about 100 files in this project and I just got tired of trying to find the files that were including resources in the wrong order. So I went with the other solution which is basically forcing libraries to load in a particular order. Basically you have to tell the compiler to ignore a particular library so that you can load it explicitly your self in the order that you choose. In my case, it was nafxcw.lib.
So under Project Properties --> Linker --> Input, I explicitly ignored nafxcw.lib and then explicitly included it at the front of the list.
So after doing this, my LNK2005 errors went away. But they were replaced with one single link error.
error LNK1224: invalid image base 0x287600000
I don't know if I fixed my previous link errors correctly and this new link error is in fact the next thing I have to deal with, or I simply created a more critical link error that is basically stopping the linking process before it gets to my original LNK2005 errors. In either case, there isn't much information I could find on this error. Microsoft doesn't say much in this link about it http://msdn.microsoft.com/en-us/library/3ya3f8wz%28v=vs.80%29.aspx
You specified an invalid base address for the image. Base addresses must be 64KB aligned (the last four hex digits must be zero) and image base must fit within a 32-bit signed or unsigned value.
This isn't all that helpful to me and there seems to be no other clues as to where this problem is coming from. I don't know what the next step is.
OK, so it looks like I have solved my own problem. Here is what I did. I needed to know where the heck this number was coming from so I simply used Notepad++ to do a word search through all the project files looking for "2876" which I got from the error message "LINK : fatal error LNK1224: invalid image base 0x287600000". I found that in the project file (.vcxproj) had the following entry in it:
<BaseAddress>0x287600000</BaseAddress>
So I opened it up and sat there wondering how this number was wrong. I mean I don't even know what this field is for. I didn't even generate this file, M$ made it. Why would the IDE create it's own input file incorrectly? Anyways, as I was trying to google this "BaseAddress" item to figure out what it was, it dawned on me that it looked like there were too many zero's. So I went back and counted and sure enough, this wasn't a 32-bit number, it was a 36-bit number. Deleted one of the zero's, recompiled, and boom it worked. Low and behold, that's kind of what the defintion I looked up, mentioned in the problem statement, hinted at looked up earlier on MSDN but it didn't click.
I don't make a habit to rummage through auto generated files very often so I never questioned that this may be the problem.

Fail to load manifest error

What does this message means? How to solve this error?
Error 1 general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified. ..\DebugObj\Example1\Example1.exe.intermediate.manifest Example1
I had the same problem on a project I inherited from a pre-2008 Visual studio.
It was not practical for me to add a Main function as sugested by the previous answer. I googled for a while but could not find the root of the problem.
A friend of mine gave me the following solution.
It turns out that the old project included a "example.manifest" file entry in the Resource File Folder in Visual Studio's Solution Explorer for the project. When trying to build the project, VS 2008 was trying to load "example.manifest", which did not exist on the new 2008 folder structor (it was not needed).
So the solution was as simple as removing the entry "example.manifest" from the Resouce Files folder. Rebuilt, and no more errors!. Hope that helps
to fix that error you need to have an entry point in your solution.
just create a main.cpp with a main method... just like this.
in "main.cpp"
void main(){}
then compile and it will get rid of the error.
Had similar issue myself. Converted a VS2005 project to VS2010.
I was using the option, Linker -> Manifest File -> Additional Manifest Dependencies: type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='' publicKeyToken='6595b64144ccf1df' language=''
The conversion garbled it into type=%27win32%27...etc
Fixing this option to the correct format, type='win32'..etc resolved the issue. But not before I accidentally used the format, type=win32...etc and received the same error.

Error while compiling a library in C#

I am trying to compile a class(sqlAccess) declared as public with few methods related to database connection in it. I am getting the following error ...
Error 1 Friend access was granted to 'SqlAccess, PublicKey=00c8', but the output assembly is named 'SQLAccess, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Try adding a reference to 'SqlAccess, PublicKey=00c8' or changing the output assembly name to match. c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll SQLAccess
What could be the reason? is there already a method of that name? I am new to programming so am unable to understand this clearly. Thank you.
This worked for me:
Open the Properties|Signing Tab. Ensure that you have "Sign the Assembly" checked and the strong name key file referenced. Save and compile the Project/Solution.
(cited from MSDN)
.NET seems to get grumpy if you give your assembly/project a name that isn't unique. In your case, SqlAccess must already exist in .NET or a referenced assembly.
The fix is to rename your assembly.
Similar issue:
Weird error in C#
That's because SqlAccess assembly has a reference which granted internal access to SqlAccess. It must be something like this [you will find it in AssemblyInfo.cs] :
[assembly: InternalsVisibleTo("Name of assembly goes here, PublicKey=")]
During compile time when compiler can not find assembly with specific PublicKey, you will get the error such as 'Friend access was granted to...'.
In order to resolve this problem one solution is to remove above attribute from source assembly, or add new public key and change it in source assembly.
Reason behind this should be either you have reinstall/update that particular dll within your solution and but old dll was not deleted properly from your solution and system.
That's why, it got worked when you change the Assembly name (from sqlAccess to sqlAccessXYZ)
I changed the Assembly name to sqlAccessXYZ and now its working, the problem is with the name. Not sure what exactly the problem, for now the issue is resolved. Thanks.

fatal error C1084: Cannot read type library file: 'Smegui.tlb': Error loading type library/DLL

I am trying to build an old version of an application which consists of VC++ projects that were written in Visual Studio 2003.
My OS is Windows 7 Enterprise (64-bit).
When I try and build the solution I get the following errors:
error C4772: #import referenced a type from a missing type library; '__missing_type__' used as a placeholder
fatal error C1084: Cannot read type library file: 'Smegui.tlb': Error loading type library/DLL.
They both complain about the following import statement:
#import "Smegui.tlb" no_implementation
This is not a case of the file path being incorrect as renaming the Smegui.tlb file causes the compiler to throw another error saying it cannot find the library.
Smegui is from another application that this one depends on. I thought perhaps I was missing a dll but there is no such thing as Smegui.dll.
All I know about .tlb files is that they are a type library and you can create them from an assembly using tlbexp.exe or regasm.exe (the later also registers the assembly with COM)
There is also an Apache Ant build script which uses a custom task to invoke devenv.com to build the projects. This is the same script that the build server originally used to build the application. It gives me the same errors when I try and run it.
The strangest thing about this is that I knew it ought to work seeing as it is all freshly checked out from subversion. I tried many different combinations of admin vs user elevation, VS vs Ant build, cleaning, release.
I have got it to build successfully about 5 times but the build seems to be non-deterministic.
If anyone can shed some light on how this tlb stuff even works or what this error might mean I would greatly appreciate it.
I found a far more reliable solution: open the tlb with oleview.exe and then close it.
Not sure what this actually does but it works every time.
I think oleview is actually one of the samples included with Visual Studio but I haven't had the time to debug it and see what it is doing.
I ran into this error because one type library was trying to load a dependent type library, which it could not find. Even though the dependent type library was in the same directory, and even though that directory was in the searchable path, the compiler would error loading the first type library, but not mention the dependent type library in the error.
To find the pseudo-missing type library, I ran Process Monitor (procman64.exe) during the compile. This showed that after the reported type library had successfully loaded, a dependent type library could not be found. It even showed all of the places that it was looking for the dependent type library, none of which were where it should have been looking (e.g.: ).
The fix was to add a <PreBuildEvent> to the project to copy the dependent .tlb file to one of the directories that was actually being searched.
<PreBuildEvent>
<Command>copy /Y ..\Lib\Interop\CWSpeechRecLib.tlb .\</Command>
</PreBuildEvent>
http://msdn.microsoft.com/en-us/library/sce74ah7%28VS.71%29.aspx
smegui.tlb is referencing some other tlb that the compiler can't find. If you have the .idl for smegui you might be able to figure out what the other is. I suspect the missing tlb is something that original build machine had registered but that your machine doesn't have registered.
A type library is a binary description of a set of interfaces, coclasses and enums. They're usually generated for COM components, in the case of tlbexp and regasm the tlb is created from the assembly metadata. For native COM components they are usually generated from an idl (Interface Description Language) file by the midl tool.
Edit:
I just noticed you're on x64 Windows. Are you building the project with a new version of Visual Studio? If so, are you targeting x86 or x64? If the latter, it may simply be a 32bit component that the compiler can't find (or less likely, a x64 component the x86 compiler can't find if you are targeting x86), for WOW64 the registry is virtualized for x86 vs. x64 applications.
Well I finally found out why I managed to get it to build sometimes and not others... sort of.
So long as I ran the build script with elevated administrator permissions and let that get as far as it could until that error occurred, then run the build script again as a protected administrator succeeded. Those steps must be done in that exact order with no other steps in between. If I try build in Visual Studio it does not work (although I did get it to succeed once). Probably some kind of virtualisation issue although it still doesn't quite make sense.
Well I don't need help on this any more and I know it's probably impossible to fully answer this question without knowing exactly what the build is doing. However if anyone does have any more thoughts I would happily receive them.
Cheers,
Steiny

Compile errors with subsonic 3.0 activerecord?

Note, I have used subsonic 2.2 extensively and love it. This is my first experience with 3.0.
I want to add subsonic to my class library rather than the website. First when I do this, and try and run the custom tool to compile the template files, I get errors saying there is not app.config file. In subsonic 2, I was able to do this and point it to my web.config file. So first question is can I use the web.config file when adding subsonic to an external class library?
The second thing that I'm experiencing are 44 identical compile errors.
This is the error from VS 2008:
Error 44 'krazyCommon.model.atDB' does not contain a definition for 'Provider' and no extension method 'Provider' accepting a first argument of type 'krazyCommon.model.atDB' could be found (are you missing a using directive or an assembly reference?) C:\dev\krazybuys\krazyCommon\model\StoredProcedures.cs 175 100 krazyCommon
and this is the code that is causing it. The end of the line this.Provider is where the error is being caused. In VS it has a squiggly line under it.
public StoredProcedure aspnet_UsersInRoles_RemoveUsersFromRoles(){
StoredProcedure sp=new StoredProcedure("aspnet_UsersInRoles_RemoveUsersFromRoles",this.Provider);
return sp;
}
I'm perplexed as I think I'm doing everything correct. Any help would be appreciated.
Many Thanks.
Update, I did find the cause of the compile error. I changed the namespace in the settings file. However, the namespace did not update in the storedprocedure.tt output. It does change for activerecord and content, but not storedprocedures. I manually changed the namespace and it compiled without error.
Is this a bug in the template or subsonic?
Is it possible to change the namespace in settings? And if so, should subsonic pick that up if you right click on activerecord, content and storedprocedures and "Run custom tool" again.
Thanks
Sorry I forgot to add that I did add an app.config file to the class library and added a conn string before I got the 44 errors.

Resources