This project has moved. For the latest updates, please go here.

no SafeHandles

Aug 18, 2012 at 2:38 PM

I'm attempting to build my first Metro app with Esent. I create a blank Metro app, and with no changes, it builds. I add the Esent.Interop reference, make no code changes, and it doesn't build. I get this message:

Cannot find type Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalide in module mscorlib.dll.

More information: I'm running on a tablet, Windows 8 RC, VS2012, and developing in C#.

Guess I'm not going anywhere until I can get this resolved. Any sage advice?

Ben

Developer
Aug 19, 2012 at 11:40 PM

Sorry, I'm about to go on vacation and don't have the source handy, so this is all from memory.

The two things that come to mind are:

-You are targeting the desktop version of CLR 4.5

-You are not including the stub of SafeHandleZeroOrMinusOneIsInvalid I included just for the Metro targetting.

The first sounds less likely because you said you specifically said that you created a blank Metro app.

So it may be the second reason. Did you add the specific Metro csproj file (EsentInterop/EsentInteropMetro.csproj) that should have been uploaded with the latest copy of the source? Also, my initial version (May 4) that I uploaded left out a couple of important stub files. Make sure you have the May 18 version.

 

 

-martin

Mar 21, 2013 at 1:27 PM
I got this exact same error with almost the same setup (I am building on a Windows 8 Pro laptop. (6.2.9200)
Using Microsoft Visual Studio Express 2012 for Windows 8 (11.0.50720) with 4.5.50709 of .NET Framework

I downloaded the pre-built dll 1.8.2.0 version of Esent.Interop and all my stuff built except for that link error. I downloaded SafeHandleZeroOrMinusOneIsInvalid.cs and tried to build that with my project. It would not build as is and it appears that System.Runtime.ConstrainedExecution was not in any of my assemblies. I commented it out (and the [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] that depended on it) and things built, but I still got the same link error (even tried changing the its namespace to Microsoft.Win32.SafeHandles to match the error) - still same error.

Any ideas?

Thanks
Developer
Mar 21, 2013 at 6:52 PM
Are you targeting a regular Desktop app or a 'Windows Store App' (formerly known as Metro) ?

I didn't include the 'windows store app' version of esentinterop in the nuget package, nor in the zip file. That was an oversight that I'll need to fix.

-martin
Mar 22, 2013 at 1:57 AM

Yes, I’m building a ‘metro’ app.

Thanks for asking,

Ben

From: martinc [email removed]
Sent: Thursday, March 21, 2013 1:53 PM
To: Ben Furino
Subject: Re: no SafeHandles [ManagedEsent:392145]

From: martinc

Are you targeting a regular Desktop app or a 'Windows Store App' (formerly known as Metro) ?

I didn't include the 'windows store app' version of esentinterop in the nuget package, nor in the zip file. That was an oversight that I'll need to fix.

-martin

Mar 22, 2013 at 8:47 AM
Yes I am (trying) also - thanks for the quick response

Just an aside - this solution seems to be the only choice for non-JavaScript metro app developers who want to use a DB. I am very surprised that MS doesn't offer a DB solution as part of their toolkit. (And it is unclear if even this solution will pass Store App certification (which is not needed in my case))
Mar 22, 2013 at 12:00 PM

I spoke to one of the MS evangelists about it, and he suggested SQL/Server Express (it goes by another name, I don’t remember what). That may be a more palatable solution.

Ben

From: richcann95 [email removed]
Sent: Friday, March 22, 2013 3:48 AM
To: Ben Furino
Subject: Re: no SafeHandles [ManagedEsent:392145]

From: richcann95

Yes I am (trying) also - thanks for the quick response

Just an aside - this solution seems to be the only choice for non-JavaScript metro app developers who want to use a DB. I am very surprised that MS doesn't offer a DB solution as part of their toolkit. (And it is unclear if even this solution will pass Store App certification (which is not needed in my case))

Mar 25, 2013 at 11:14 AM
From my understanding SQL is only available as a service. My app (running on a tablet) needs to access a local DB offline. If my understanding is incorrect, please point me to any links that talk about this as all discussions I have found only talk about using it connected to a server.
Mar 25, 2013 at 8:05 PM
They may have been referring to the LocalDB version of SQL Server Express (http://msdn.microsoft.com/en-us/library/hh510202.aspx). It's geared more towards use by developers though. Both can use a file on the local file system identified in the connection string but since they are installed and run as a separate process, probably aren't acceptable for use on a tablet I would think.

Eric
Mar 25, 2013 at 8:18 PM
Hello "richcann95"

We have been using ManagedESEnt on Surface table (WinRT) for the past 6 months. It works perfectly and it passes the AppStore inspection.
We are using AppStore to install our app on other Surface tables for our employees anywhere.

They use the ESE database as an offline DB. When they find an internet connection, they send the data back as XML. Which can be stored in any database.

What problem do you have with ManagedESEnt?
Mar 26, 2013 at 11:05 AM
Hello "baygnik",
The link error I am getting is identical to what bjfurino posted on the first entry of this thread.  My build conditions are detailed in my post on this thread of Thursday - 9:27am.   Not sure what the difference in our environment is.  Two thoughts:
1) Where/how are you getting your interop dll (building from source or the zip file)
2) what version are you using (I am using 1.8.2 which hasn't been out for 6 months - have you updated to the latest version?


BTW: martinc seems to know what the problem is, I am just waiting for his update (or I think I could break down and build from source - which if I am reading correctly would also fix the problem)
Mar 26, 2013 at 12:48 PM
Understood.

I always build using the code, so it will fit my environment. I am on Windows 8 using VS2012.
We did have some issues with WinRT way of finding files and "ASYNC" way of doing things. But that was part of our growing pain.

If you need an ISAM database that is on every Windows machine and tablet, then you can't go wrong with ESE and this managed package. Although, the front-end approach for Windows and WinRT are completely different.

I suggest you try to fit WinRT first, then move your code to be compatible with Windows op/sys or what is now called desktop. I hope that makes sense.

bayganik
Developer
Mar 26, 2013 at 7:18 PM
By the way, I'm working on a new drop now that has the signed version for desktop and metro.

We're no longer allowed to use the 'Metro' word, so the non-desktop version will be called Esent.Interop.Wsa.dll (for 'Windows Store App'). I'm not incredibly thrilled about the new name, but I can't always get what I want... :)

-martin