I'm attempting to build a library (Medsphere.Widgets) on Ubuntu, and it's throwing me an error. I've had a good search around, but nobody seems to have an answer for it. The configure script works fine, and completes with no warnings or errors. When I go to run the make, it does this:
polynomial#ubuntu:~/Projects/Medsphere/$ make
Making all in src
make[1]: Entering directory `/home/polynomial/Projects/Medsphere/src'
/usr/bin/mcs /target:library /out:Medsphere.Widgets.dll -r:/usr/lib/pkgconfig/../../lib/cli/pango-sharp-2.0/pango-sharp.dll -r:/usr/lib/pkgconfig/../../lib/cli/atk-sharp-2.0/atk-sharp.dll -r:/usr/lib/pkgconfig/../../lib/cli/gdk-sharp-2.0/gdk-sharp.dll -r:/usr/lib/pkgconfig/../../lib/cli/gtk-sharp-2.0/gtk-sharp.dll -r:/usr/lib/pkgconfig/../../lib/cli/glib-sharp-2.0/glib-sharp.dll -r:/usr/lib/mono/2.0/Mono.Cairo.dll ./CPaned.cs ./FBox.cs ./GridView.cs ./CairoHelper.cs ./IconLayout.cs ./ICairoCellRenderer.cs ./BoxCellRenderer.cs ./PixbufCellRenderer.cs ./TextCellRenderer.cs ./graph/AxisLocation.cs ./graph/AxisSizeGroup.cs ./graph/BaseTreeModelPlot.cs ./graph/DateTimeAxis.cs ./graph/EventPlot.cs ./graph/Graph2D.cs ./graph/Graph.cs ./graph/GtkStyleProvider.cs ./graph/HistogramPlot.cs ./graph/IAxis.cs ./graph/IPlot.cs ./graph/IStyleProvider.cs ./graph/ITreeModelPlot.cs ./graph/LabelAxis.cs ./graph/Legend.cs ./graph/LinearAxis.cs ./graph/LinePlot.cs ./graph/LinkedLinePlot.cs ./graph/PlotColor.cs ./graph/PointShape.cs ./graph/ReferenceRangePlot.cs
./IconLayout.cs(414,25): error CS0029: Cannot implicitly convert type `Cairo.Context' to `Cairo.Context'
./IconLayout.cs(414,25): The type `Cairo.Context' has two conflicting definitions, one comes from `Mono.Cairo, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' and the other from `Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' (in the previous error)
Internal(1,1): The type `Cairo.Context' has two conflicting definitions, one comes from `Mono.Cairo, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' and the other from `Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' (in the previous error)
./IconLayout.cs(920,41): error CS1502: The best overloaded method match for `Gdk.CairoHelper.SetSourceColor(Cairo.Context, Gdk.Color)' has some invalid arguments
/usr/lib/cli/gdk-sharp-2.0/gdk-sharp.dll (Location of the symbol related to previous error)
./IconLayout.cs(920,41): error CS1503: Argument `#1' cannot convert `Cairo.Context' expression to type `Cairo.Context'
./IconLayout.cs(920,41): (equally named types possibly from different assemblies in previous error)
/usr/lib/mono/gac/Mono.Cairo/2.0.0.0__0738eb9f132ed756/Mono.Cairo.dll (Location of the symbol related to previous error)
/usr/lib/mono/gac/Mono.Cairo/1.0.5000.0__0738eb9f132ed756/Mono.Cairo.dll (Location of the symbol related to previous error)
Compilation failed: 3 error(s), 0 warnings
I can only imagine that two versions of Cairo are conflicting, but I can't figure out how to fix it. Any ideas?
Just to clear this one up:
I modified config.status to use gmcs rather than just mcs and patched all Mono.Cairo references so that they point at the version-specific DLL, rather than the generic one in the GAC. After patching a couple of cast bugs in the lib, it works great!
Related
I am using dnLib to generate MSIL assemblies dynamically from a custom language I'm writing, named CSASM:
string absolute = Path.Combine(Directory.GetCurrentDirectory(), forceOutput ?? $"{asmName}.exe");
ModuleDefUser mod = new ModuleDefUser(asmName, Guid.NewGuid(), new AssemblyRefUser(new AssemblyNameInfo(typeof(int).Assembly.GetName().FullName))){
Kind = ModuleKind.Console,
RuntimeVersion = "v4.0.30319" //Same runtime version as "CSASM.Core.dll"
};
var asm = new AssemblyDefUser($"CSASM_program_{asmName}", new Version(version));
asm.Modules.Add(mod);
// Adding attribute code omitted for brevity
//Adds types to the module and constructs methods and method bodies for those types based on the CSASM source file in question
Construct(mod, source);
mod.Write(absolute);
The generation of the executable is working as intended.
However, when trying to run this executable, the TypeLoadException below is thrown:
System.TypeLoadException: Could not load type 'CSASM.Core.IntPrimitive' from assembly
'CSASM_program_Example, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' due to
value type mismatch.
at Example.Program.csasm_main()
CSASM_program_Example being the name of assembly for the generated executable, Example.exe.
The type IntPrimitive is actually found in the CSASM.Core.dll assembly, which is also in the same folder as the generated executable.
Due to the extreme lack of documentation surrounding dnLib, I'm essentially stumbling around in the dark here.
In short, is there a reason why the type is trying to be loaded from the wrong assembly?
If so, is there a way that I can remedy this?
Viewing the assembly in dnSpy shows the TypeRefs and MemberRefs referencing correct assemblies, which makes this predicament even more frustrating.
After a very thorough examination of a dnLib DLL, the problem was due to me using Importer.ImportDeclaringType(Type).ToTypeDefOrRef(), which caused value-type TypeSigs to be registered as class-type TypeSigs instead.
Even though the docs say to use Importer.ImportDeclaringType(Type) over Importer.ImportAsTypeSig(Type) for method and field declarations, you really shouldn't be using it.
I am trying to connect to a SignalR hub using a powershell script. I am very new to powershell, so please excuse any rookie mistake.
I have set up a minimal not working example of what I have tried here :
Gist
Relevant code:
Load dlls
$dllFolder = -join((Get-Item -Path ".\" -Verbose).FullName, "\bin\Debug\")
[string[]] $dllPathsToLoad = #("\Newtonsoft.Json.dll", "\Microsoft.AspNet.SignalR.Client.dll")
$token = "insertyourtokenhere"
function LoadDllPaths($dlls)
{
foreach ($dll in $dlls)
{
$dllpath = $dllFolder + $dll
[System.Reflection.Assembly]::LoadFrom($dllpath)
}
}
[...]
LoadDllPaths($dllPathsToLoad)
Create HubConnection:
$server = "https://localhost/rest/"
[...]
$hub = New-Object Microsoft.AspNet.SignalR.Client.HubConnection($server)
Steps:
Create a new Visual Studio project
Add Newtonsoft.Json v10.0.2 Nuget package (latest)
Add Microsoft.AspNet.SignalR.Client v2.2.2 Nuget package (latest)
Add powershell script to the root of the project
With powershell (run as admin), type .\HubConnectionTestsScript.ps1
Result:
View on imgur
Error : System.Management.Automation.MethodInvocationException: Exception calling ".ctor" with "1" argument(s): "Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified." ---> System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
at Microsoft.AspNet.SignalR.Client.Connection..ctor(String url, String queryString)
at Microsoft.AspNet.SignalR.Client.HubConnection..ctor(String url, Boolean useDefaultUrl)
--- End of inner exception stack trace ---
at System.Management.Automation.DotNetAdapter.AuxiliaryConstructorInvoke(MethodInformation methodInformation, Object[] arguments, Object[] originalArguments)
at System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(Type type, ConstructorInfo[] constructors, Object[] arguments)
at Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(Type type, ConstructorInfo[] constructors, Object[] args)
This signalR source code object seems to be the problem, I just don't see what part of it can be throwing this error.
Question:
Why does the error mention Newtonsoft.Json v6.0.0 when signalR dependencies say >=6.0.4, and I have 10.0.2?
Am I doing anything wrong in my Powershell script which could be causing this?
Thank you very much! Any help is appreciated at this point
I managed to solve this issue with some help from a colleague. Sharing the solution here in case anyone ever struggles on the same problem.
It appears that one of SignalR dependencies tries to load an old version of Newtonsoft.Json. We can force it to redirect him to our own instance of Newtonsoft.Json
Inspired by this gist, here is the idea :
When you load your Json Assembly, store it in a variable
$newtonsoftAssembly = [System.Reflection.Assembly]::LoadFrom($dllFolder + "\Newtonsoft.Json.dll")
Afterwards, setup the redirect bindings. My best guess is that this intercepts any call to load an assembly, giving us the opportunity to return our own Json assembly instead of letting him fail to find the version he wants (6.0.0 in my case).
function RedirectJsonBindings()
{
$onAssemblyResolveEventHandler = [System.ResolveEventHandler] {
param($sender, $e)
# You can make this condition more or less version specific as suits your requirements
if ($e.Name.StartsWith("Newtonsoft.Json")) {
Write-Host "Newtonsoft assembly" $e.Name -ForegroundColor DarkGreen
return $newtonsoftAssembly
}
foreach($assembly in [System.AppDomain]::CurrentDomain.GetAssemblies()) {
if ($assembly.FullName -eq $e.Name) {
return $assembly
}
}
return $null
}
[System.AppDomain]::CurrentDomain.add_AssemblyResolve($onAssemblyResolveEventHandler)
}
And finally, at the end of your script, unbind
# Detach the event handler (not detaching can lead to stack overflow issues when closing PS)
[System.AppDomain]::CurrentDomain.remove_AssemblyResolve($onAssemblyResolveEventHandler)
So well I've searched tons of threads regarding the same issue but I can't seem to work. I know the exact same problem though.
So there's a
SellControl.DLL
that I added a delegate and an event as you can see here.
public delegate void CashCreditStatusDel(string cardNo, decimal amount, string extraText, string token, string docNr, bool status);
public static event CashCreditStatusDel SwitchOperationStatus;
Now I need that event inside another class so I reference the SellControl.dll and run it. Eeverything in my PC works fine, flawless though when I put it on test machine that our tester uses - it drops an error
[08:42:46] FATAL (Kernel): Inner exception: System.TypeLoadException:
Could not load type 'SellControls.CashCreditStatusDel ' from assembly
'SellControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at Plugins.CardCreditOperation.Display()
So I tracked an error to Display() method
SellControl.SwitchOperationStatus += InvokeData;
I subscribe my method InvokeData to method inside a SellControl, if I remove this line - code doesn't crash but I don't subscribe to event.
As I can understand somehow in the test machine there's GAC that has the old version of SellControl.dll and uses it instead of mine? I'm struggling with it for like 2 hours now.
Okay so what I did I went to my assembly and in properties I added a file version and raised assembly version and wrote a date in the comments to really verify if I have the same DLL all over. After doing that I rebuilt - voila.
It somehow worked.
I'm trying to connect to CRM using steps declared in this link
https://msdn.microsoft.com/en-us/library/gg695790.aspx
Error
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0012: The type 'System.Data.Services.IUpdatable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Source Error:
Line 192816: /// </summary>
Line 192817: [System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "7.0.0000.3543")]
Line 192818: public partial class XrmServiceContextr : Microsoft.Xrm.Client.CrmOrganizationServiceContext
Line 192819: {
Line 192820:
Source File: c:\Users\Gevor\Documents\Visual Studio 2013\Projects\TestCRM\TestCRM\App_Code\Xrm.cs Line: 192818
Command line parameters
c:\DynamicsCRM\SDK\Bin>CrmSvcUtil.exe /out:Xrm.cs
/url:https://Organization/XRMServices/2011/Organization.svc
/domain:DOMAIN /username:USERNAME /password:PASSWORD /namespace:Xrm
/serviceContextName:XrmServiceContextr
/codeCustomization:"Microsoft.Xrm.Client.CodeGeneration.CodeCustomization,
Microsoft.Xrm.Client.CodeGeneration"
If System.Data.Services is not the GAC, it neeeds to be merged in your assembly, not only referenced.
You need to add a System.Data.Services reference to your TestCRM application.
How would one go about wrapping WebGL in Script#.
I tried to add stuff to the source code but get compile errors I don't understand.
[ScriptIgnoreNamespace]
[ScriptImport]
[ScriptName("webGL")]
public sealed class WebGL
{
[ScriptName("fooGL")]
public void Foo(string test)
{
}
}
Error 1 The base class or interface 'System.FormatException' in
assembly 'mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' referenced by type
'System.UriFormatException' could not be
resolved c:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll Web
Or is there a way better way to add WebGL support as a lib rather then adding it directly to the main source?
EDIT: Looks like that compiler error was coming from VS from auto adding System.dll to the project and it shouldn't be. After removing it now compiles. So now the question is what is the best way to wrap a javaScript API in Script# ??
You should look at the S# source on github for how wrappers are written. They're simply classes tagged with ScriptImport attribute and the internal methods/properties have empty values/bodies.
Look at the source here.