Sqlite - Entity Framework 4 - CAS Assertion Fehler

  • C#

    Sqlite - Entity Framework 4 - CAS Assertion Fehler

    Ich wollte, da unsere Schule kein .NET FW 4 und schon garkein .NET 4.5 auf den Rechnern hat, das Mono Framework nutzen und die Assemblys dann von einem Framework unabhängig machen.
    Funktioniert auch z.T. bestens, nur habe ich ein Problem mit der Auswahl eines Datenbank Providers.
    DataSet kommt nicht in Frage, weil ich dann keine 1:1 Relation bauen kann.
    SqlCe fällt raus, da das Mono Framework kein SqlCe Pendant hat.
    Was bleibt ist Sqlite.

    Was denkt man sich also? Nutz ich Sqlite.NET oder Mono.Data.Sqlite? Korrekt, also Sqlite.NET einbauen. Referenz auf System.Data.SQLite und System.Data.SQLite.Linq gesetzt, kompiliert. Ausgeführt (.NET 4.5) und yay es geht.
    Das ganze noch schnell per

    Quellcode

    1. AliveDevil@Joeran-Main /cygdrive/d/Dokumente/Projekte/WirtschaftsSimulation/WirtschaftsSimulation/bin/Debug
    2. $ mkbundle -o Simulation.exe WirtschaftsSimulation.exe --deps
    unabhängig machen und dann solls das gewesen sein.
    Rechner denkt sich so "pff, das mach ich nich" und lässt die Anwendung nicht starten. Warum auch? SQLite is ja nich da.
    Also

    Quellcode

    1. $ mkbundle -o Simulation.exe WirtschaftsSimulation.exe System.Data.SQLite.dll --deps
    ausgeführt und? -Richtig, nichts.
    Schmeißt man also SQLite.NET in die Ecke und holt sich Mono.Data.Sqlite heran.
    Also schnell die App.config manipuliert

    XML-Quellcode

    1. <system.data>
    2. <DbProviderFactories>
    3. <add name="Mono Sqlite Provider" invariant="Mono.Data.Sqlite" description="Mono Framework Data Provider for SQLite" type="Mono.Data.Sqlite.SqliteFactory, Mono.Data.Sqlite, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
    4. </DbProviderFactories>
    5. </system.data>
    und es sollte ja gehen, richtig?
    Das .NET 4.5 meint jetzt aber, dass

    Quellcode

    1. CAS-Assertionen können nicht in SecurityTransparent-Methoden durchgeführt werden.

    Das läuft natürlich auch nicht:

    Quellcode

    1. $ mkbundle -o Simulation.exe WirtschaftsSimulation.exe Mono.Data.Sqlite.dll --deps
    2. OS is: Windows
    3. Sources: 2 Auto-dependencies: True
    4. embedding: D:\Dokumente\Projekte\WirtschaftsSimulation\WirtschaftsSimulation\bin\Debug\WirtschaftsSimulation.exe
    5. config from: D:\Dokumente\Projekte\WirtschaftsSimulation\WirtschaftsSimulation\bin\Debug\WirtschaftsSimulation.exe.config
    6. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\EntityFramework.dll
    7. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\mscorlib.dll
    8. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.dll
    9. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\Mono.Security.dll
    10. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.Configuration.dll
    11. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.Xml.dll
    12. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.Security.dll
    13. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.Core.dll
    14. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\Mono.Posix.dll
    15. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.Data.dll
    16. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\Mono.Data.Tds.dll
    17. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.Transactions.dll
    18. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.EnterpriseServices.dll
    19. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.Runtime.Serialization.dll
    20. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.Xml.Linq.dll
    21. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.ComponentModel.DataAnnotations.dll
    22. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\Microsoft.CSharp.dll
    23. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\Mono.CSharp.dll
    24. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.Windows.Forms.dll
    25. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\System.Drawing.dll
    26. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\Accessibility.dll
    27. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\Mono.WebBrowser.dll
    28. embedding: C:\PROGRA~2\MONO-2~1.4\lib\mono\4.5\Mono.Data.Sqlite.dll
    29. Compiling:
    30. as -o temp.o temp.s
    31. i686-pc-mingw32-gcc -U _WIN32 -g -o Simulation.exe -Wall temp.c `pkg-config --cflags --libs mono-2|dos2unix` temp.o
    32. temp.c: In function ‘install_dll_config_files’:
    33. temp.c:87:2: Warnung: pointer targets in passing argument 2 of ‘mono_register_config_for_assembly’ differ in signedness
    34. C:/PROGRA~2/MONO-2~1.4/include/mono-2.0/mono/metadata/assembly.h:101:15: Anmerkung: expected ‘const char *’ but argument is of type ‘const unsigned char *’
    35. Done


    Kann mir jemand sagen, warum der den Müll a) nicht starten will und mir b) den "CAS-Assertionen können nicht in SecurityTransparent-Methoden durchgeführt werden"-Fehler wirft und wie ich die zwei Sachen beheben kann?
    (wenn b behoben wurde, sollte a automatisch laufen)