开发者

Windows Phone 7: All I get is System.MethodAccessException

This is my first time to develop apps in Windows Phone 7 and I was not that welcome. LOL.

Anyways, my problem is this MethodAccessException and am not sure why it keeps throwing me that exception.

Here's what I was 开发者_JAVA技巧trying to do.

  1. Getting Application StartUp Path by: System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase

    System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName

    API:

    [DllImport("coredll.dll", SetLastError = true)]

    public static extern int GetModuleFileName(IntPtr hModule, StringBuilder lpFilename, int nSize);

  2. Try to just enumerate some files

    int c = Directory.GetFiles(@"\").Length;

    System.Diagnostics.Debug.WriteLine("total files: " + c);

and am not sure what else since I just started coding. I have a big app in mind, and it will cover Registry IO, File IOs, and Database. But if this MethodAccessException keeps blocking my way, I'd rather be dead.

Am using Windows Phone 7.0

6176.WM7 RC1Escrow(buildlab).20100406 1457


You cannot use Reflection or P/Invokes in Phone 7.

For File I/O you should be using IsolatedStorageFile for dealing with files. See this example (among many on the web).

There is no Registry access (maybe explaining why you think you need it can lead us to providing alternatives).

For Database access, there are lots of options. Depends on where you want the database (local/remote/cloud), what engine you want, ORM preferences, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜