سؤال

When I use the SqlDataProvider<ConnectionString = "..."> type provider it type-checks fine in Visual Studio and Xamarin Studio under Windows. However, in Xamarin Studio under Mac OS X it fails with the following error:

error FS3033: The type provider 'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders' reported an error: Error reading schema. No access to the given key

How can I fix this problem and get type-checking to work again?

هل كانت مفيدة؟

المحلول

This issue occurs because the SqlDataProvider<...> uses the Windows registry under the hood to find out the .NET SDK path so that it knows where SqlMetal.exe lives. See the 'Util.fs' file for more details.

You can fix the initial registry problem by following the steps below.

  1. Create a registry folder here (or somewhere similar depending on your Mono version):

    /Library/Frameworks/Mono.framework/Versions/3.2.5/etc/mono/registry/

  2. Locate SqlMetal.exe. Its folder is likely the SDK install location that we will use in the next step.

  3. Add the registry key that the type provider needs manually. You can do this in F# interactive by executing this (again the version numbers may need changing):

    let key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools")
    key.SetValue("InstallationFolder", "/Library/Frameworks/Mono.framework/Versions/3.2.5/lib/mono/4.5/")
    

However, this only gets you as far as the next error.

error FS3033: The type provider 'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders' reported an error: Error reading schema. Could not find file "/var/folders/03/fsl9pbz96sqdnsgxjqf6pmph0000gn/T/tmp72b90b49.dbml".

This is because the type-provider passes additional arguments to SqlMetal.exe (e.g., /timeout:<value>) and the Mono version seems to assume the last argument is the output file.

It looks like either the type-provider or SqlMetal.exe need to change. It may make most sense to change the type-provider, as we can remove the registry lookup for Mono. If the type-provider is changed it will also make deployment easier (i.e., you don't have to fix the mono registry on the deployment target machines).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top