Class not found error in Godot Mono Version - c#

So I linked a .dll file of a library I made myself in the .csproj file of my Godot project:
<ItemGroup>
<Reference Include="BiomeLibrary">
<Private>False</Private>
<HintPath>$(ProjectDir)/lib/BiomeLibrary.dll</HintPath>
</Reference>
</ItemGroup>
and then I wanted to use it in a C# script, but everytime I do that, I get this Error:
E 0:00:00.776 can_instance: Cannot instance script because the class 'BLTest' could not be found. Script: 'res://BLTest.cs'.
<C++-Fehler> Method failed. Returning: __null
<C++-Quellcode>modules/mono/csharp_script.cpp:2892 # can_instance()
BLTest is the class of the script.
I don't get it, please help me.
I tried it in different scripts and projects, but always the same.

Related

Could not load file or assembly Microsoft.Data.SqlClient, Version=5.0.0.0

Facing following issue after deploying app to azure app service:
Unhandled exception. System.IO.FileNotFoundException: Could not load
file or assembly 'Microsoft.Data.SqlClient, Version=5.0.0.0,
Culture=neutral, PublicKeyToken=***********'. The system cannot find
the file specified.
Locally everything works as fine.
Microsoft.Data.SqlClient presented in site/wwwroot
Runtime Stack: Dotnetcore - 6.0
Main app and all class libs on .net6
Server Operating System: Linux
Microsoft.Data.SqlClient presented as reference from Microsoft.EntityFrameworkCore.SqlServer (v.7.0.2)
Tried different kinds of Nuget Packages versions - still have same issue
Tried to install Microsoft.Data.SqlClient (latest version & 5.0.0.0) directly into projects - still the same
The solution for us was to:
Locate the actual DLL file (Microsoft.Data.SqlClient.dll) on the developer's desktop filesystem (easy to find; once you're referenced it using NuGet it gets copied to multiple places)
Add it to the web project (we placed it right in the root)
Mark it (via Properties tool window) as Copy Always
Step 3 results in our .csproj file looks like this:
<ItemGroup>
<None Update="Microsoft.Data.SqlClient.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

Alea GPU Project Setup

I am trying to get the "simple to use" Alea Libary to work (I have a RTX2080, so this shouldn't be the Problem).
The UI is WPF based and implemented in a .NET Core 3.1 project. It injects a "GpuCalculator" object into the "Core.Lib" (.Net Standard 2.1).
I created a .Net Standard 2.0 Class-Library for the execution (Core.Calculations Project). The GpuCalculator is implemented here. I installed the Alea NuGet Package (Version 3.0.4) along with the FSharp.Core (Version 5.0.1), which is needed from Alea.
At first I had the same Problem described here: How to setup project using Alea GPU
That's why I added the following lines to my csproj File:
<ItemGroup>
<Reference Include="Alea">
<HintPath>$(NuGetPackageRoot)\alea\3.0.4\lib\net45\alea.dll</HintPath>
</Reference>
<Reference Include="Alea.IL">
<HintPath>$(NuGetPackageRoot)\alea\3.0.4\lib\net45\Alea.IL.dll</HintPath>
</Reference>
<Reference Include="Alea.Parallel">
<HintPath>$(NuGetPackageRoot)\alea\3.0.4\lib\net45\Alea.Parallel.dll</HintPath>
</Reference>
</ItemGroup>
The Problem now is that whenever I want to access "Gpu.Default", an Exception is thrown (NullReferenceException) from the F# Code. Even a simple access to Default doesn't work:
var gpu = Gpu.Default;
Results in an Error like this:
at Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicFunctions.UnboxGeneric[T](Object source) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\prim-types.fs:line 647
I also tried to switch my target platform from "Any CPU" to "x64" because I saw the hint somewhere. It had no effect though :(
I am thankful for every help!
Do I need any other NuGet packages?
Should I probably switch to something different? Cudafy? OpenGL (via OpenTK) Compute-Shaders? Vulcan (C#?)...?
edit:
On my Latop I get the following error when I want to access the Gpu.Default:
Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'.

UWP - Class librairies and PRI file generation

In my UWP solution, I have a ClassLibrary1 project (with a BlankPage1.xaml) and a ClassLibrary2 project that references the ClassLibrary1 project (with a BlankPage2.xaml).
I'm doing 2 NuGet packages (one for ClassLibrary1 and another for the ClassLibrary2).
In an UWP app, I added the ClassLibrary2 NuGet package. But, when I compile this app, I get these compilation errors:
Error: Could not copy the file "C:\Users\xxx\.nuget\packages\classlibrary2\1.0.0\lib\uap10.0.16299\ClassLibrary1\BlankPage1.xbf" because it was not found.
Error: Could not copy the file "C:\Users\xxx\.nuget\packages\classlibrary2\1.0.0\lib\uap10.0.16299\ClassLibrary1\BlankPage1.xaml" because it was not found.
Error: Could not copy the file "C:\Users\xxx\.nuget\packages\classlibrary2\1.0.0\lib\uap10.0.16299\ClassLibrary1\ClassLibrary1.xr.xml" because it was not found.
I noticed that the ClassLibrary2.pri file includes these 3 files and it shouldn't because they are included in the ClassLibrary1 NuGet package.
How can I indicate to not include these files in the ClassLibrary2.pri ?
This is a sample project that reproduces the problem : https://github.com/kakone/PriGeneration/
I found a workaround by copying a custom filtered.layout.resfiles file to the obj folder before the MSBuild target named _GenerateProjectPriFileCore.
I added these lines in my .csproj :
<Target Name="CustomPriFileGeneration" BeforeTargets="_GenerateProjectPriFileCore" Condition=" '$(Configuration)'=='Release' ">
<Copy SourceFiles="$(ProjectDir)\filtered.layout.resfiles" DestinationFolder="$(BaseIntermediateOutputPath)\$(Configuration)\$(TargetFramework)" />
</Target>
and a filtered.layout.resfiles file in my project :
ClassLibrary2\BlankPage2.xaml
ClassLibrary2\ClassLibrary2.xr.xml

VS2019 extension using IDebugEventCallback2

I created a new VS extension using VS2019 16.1.6.
and I added this using statement
using Microsoft.VisualStudio.Debugger.Interop;
and added the interface IDebugEventCallback2 to my class
public sealed class VSIXProject1Package : AsyncPackage, IDebugEventCallback2
Not I get the error:
error CS0433: The type 'IDebugEventCallback2' exists in both 'Microsoft.VisualStudio.Debugger.Interop, Version=8.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'Microsoft.VisualStudio.Debugger.InteropA, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
How can I get rid of this error? Or is there an other way to react to debugger events than using IDebugEventCallback2?
edit:
Problem reported to Microsoft:
https://developercommunity.visualstudio.com/content/problem/651199/vs2019-extension-using-idebugeventcallback2.html
VS2019 uses PackageReference format to manage nuget packages for VSIX project.
And by default it will reference Microsoft.VisualStudio.SDK and Microsoft.VSSDK.BuildTools package.Also, since Microsoft.VisualStudio.SDK package have dependencies on many other packages, this project will also reference those packages.
See this simple structure:
Microsoft.VisualStudio.SDK
......(other dependencies)
--Microsoft.VisualStudio.Debugger.Interop
--Microsoft.VisualStudio.OLE.Interop
--Microsoft.VisualStudio.Debugger.Interop.10.0
--Microsoft.VisualStudio.Debugger.InteropA
......(11.0,12.0,14.0,15.0)
--Microsoft.VisualStudio.Debugger.Interop.16.0
--Microsoft.VisualStudio.Debugger.InteropA
So it's clear this issue results from the VSIX project adds reference to both Microsoft.VisualStudio.Debugger.Interop and Microsoft.VisualStudio.Debugger.InteropA.
These two assemblies have the same namespace Microsoft.VisualStudio.Debugger.Interop, and all have IDebugEventCallback2 Interface. I think it's why causes this issue.
As a workaround:
Normal we can use extern alias for this situation. But it hasn't supported for PackageReference format yet. Fortunately I found a good hint from gertjvr. So all we need is:
Unload the project=>Edit the xxx.csproj=>Add the content below into the project file:
<Target Name="ChangeAliasesOfStrongNameAssemblies" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">
<ItemGroup>
<ReferencePath Condition="'%(FileName)' == 'Microsoft.VisualStudio.Debugger.Interop'">
<Aliases>signed</Aliases>
</ReferencePath>
</ItemGroup>
</Target>
You can change the ReferencePath to Microsoft.VisualStudio.Debugger.InteropA if you want to use the Interface from this assembly. It depends on your need.

unable to import and use RestSharp in Azure functions using Nuget

So the situation is as follows:
I have a azure-botbuilder created chatbot running on a consumption-plan based Azure function. Now I would like to use RestSharp to consume and send requests for REST APIs.
However I followed all the instructions to install NuGet Packages for RestSharp and add the requisite dependencies in my project.json, and the "using RestSharp;" import statement inside the code, however for some reason it seems unable to import the library and always gives the error "The type or namespace name 'RestSharp' could not be found (are you missing a using directive or an assembly reference?)"
Heres my project.json:
{
"frameworks": {
"net46":{
"dependencies": {
"Microsoft.Bot.Builder.Azure": "3.2.5",
"RestSharp": "105.2.3"
}
}
}
}
If you make an Azure function in version 2.x you need to do this in a different way.
Create a new file called function.proj. This file has an XML structure for importing libraries via Nuget.
Here is my example importing RestSharp.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="RestSharp" Version="106.6.8"/>
</ItemGroup>
</Project>
Once you hit save the console will tell you that it is restoring packages. Just wait a minute for it to finish. Mine had a compilation error and Azure restarted the package restore itself and eventually compiled successfully after a minute or so.
Here is where I found this solution: https://stackoverflow.com/a/53053897/4821686

Categories