azurefx / dotnet.jl Goto Github PK
View Code? Open in Web Editor NEWJulia ❤️ .NET
License: MIT License
Julia ❤️ .NET
License: MIT License
If I try this, there is no error, but the result is wrong
julia> n=Int32(0); T"System.Int32".TryParse("1", n); n
0
not sure how to include the 'out' parameter
Hi,
I'm trying to set music tags using taglibsharp dll (downloadable from https://www.nuget.org/packages/TagLibSharp/ : download package, extract content -e.g. 7zip- and get dll from netstandard2.0).
I'm able to get and set (some) tags for .mp3 file. My code :
using DotNET
dllpath = "TagLibSharp.dll"
taglibsharp = T"System.Reflection.Assembly".LoadFrom(dllpath)
taglibfile = taglibsharp.GetType("TagLib.File")
filepath = "[PATH_TO_MP3_FILE]"
obj = taglibfile.Create(filepath)
println(obj.Tag.Title) # print title of the song
obj.Tag.Title = "Test Title"
obj.Save() # now if you check the title tag for the mp3 file, it has "Test Title"
However, there are some tags I can't write.
println(obj.Tag.Year) # I can access and get the Year tag
obj.Tag.Year = 2010 # This lead to an error :
ERROR: CLRException: System.MissingMethodException: Method 'TagLib.NonContainer.Tag.Year' not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at CLRBridge.Meta.InvokeMember(IntPtr type, String name, BindingFlags bindingFlags, IntPtr binder, IntPtr target, IntPtr[] providedArgs, UInt32 argCount, IntPtr& exception)
Stacktrace:
[1] track_and_throw(::UInt64) at C:\Users\axelv\.julia\packages\DotNET\aiT1M\src\CLRBridge.jl:46
[2] InvokeMember(::UInt64, ::String, ::UInt32, ::Int64, ::UInt64, ::Array{UInt64,1}) at C:\Users\axelv\.julia\packages\DotNET\aiT1M\src\CLRBridge.jl:319
[3] invokemember(::UInt32, ::CLRObject, ::CLRObject, ::Symbol, ::Array{String,1}) at C:\Users\axelv\.julia\packages\DotNET\aiT1M\src\marshalling.jl:69
[4] setproperty!(::CLRObject, ::Symbol, ::Array{String,1}) at C:\Users\axelv\.julia\packages\DotNET\aiT1M\src\operators.jl:99
[5] top-level scope at REPL[22]:1
I have the same behaviour for some other tags.
When I do the same operation in PowerShell, everything works fine and I can edit the tag. So I guess the issue is not linked with TagLibSharp ?
Is there something I am doing wrong ? Is this an actual issue with DotNET.jl ? Is there another way to edit the tag.
Any idea ?
Thanks
Hi
This package looks very interesting!
Can you provide an example on how to call methods from a DLL? If I have a Class Library with a single file:
namespace JuliaTest
{
public class Foo
{
public double Bar(double x)
{
return 2 * x;
}
}
}
How do I call Bar
from the generated dll? (Please correct me if this is the wrong way to generate the dll :-))
Thanks.
Hello,
Thanks again for this package!
When converting arrays from dotNET julia array, I am using the function collect
. However, the function takes a long time to run for an array conversion:
arr = T"System.Array".CreateInstance(T"System.Byte", 1024 * 1240)
@time collect(arr)
# 3.537783 seconds (38.09 M allocations: 1.335 GiB, 9.71% gc time)
Is there a faster way to convert the arrays?
Thanks,
in the examples you supply is missing: "using DotNET"
OS -is- Windows 10 (x86_64-w64-mingw32)
Julia Version 1.6.2 -and- LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
dotnet --version >> 5.0.302
PS: from the package manager:
Project.toml [5091b313] DotNET v0.1.2 https://github.com/azurefx/DotNET.jl#master
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
the following works just fine:
julia> for i in 1:10000 GlobalDictInterface.Update("c1", "k$i", "v$i"^1000) end
But stress testing it it doesn't:
julia> while true; for i in 1:1000 GlobalDictInterface.Update("c1", "k$i", "v$i"^1000) end; sleep(1); end
ERROR: CLRException: System.MissingMethodException: Method 'GlobalDictInterfaceForJulia.GlobalDictInterface.Update' not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at CLRBridge.Meta.InvokeMember(IntPtr type, String name, BindingFlags bindingFlags, IntPtr binder, IntPtr target, IntPtr[] providedArgs, UInt32 argCount, IntPtr& exception)
Stacktrace:
[1] track_and_throw(exhandle::UInt64)
@ DotNET.CLRBridge C:\Users\<user>\.julia\packages\DotNET\Rx490\src\CLRBridge.jl:46
[2] InvokeMember(type::UInt64, name::String, bindingFlags::UInt32, binder::Int64, target::UInt64, providedArgs::Vector{Union{}})
@ DotNET.CLRBridge C:\Users\<user>\.julia\packages\DotNET\Rx490\src\CLRBridge.jl:325
[3] invokemember(::UInt32, ::CLRObject, ::CLRObject, ::Symbol)
@ DotNET C:\Users\<user>\.julia\packages\DotNET\Rx490\src\marshalling.jl:83
[4] invokemember
@ C:\Users\<user>\.julia\packages\DotNET\Rx490\src\marshalling.jl:94 [inlined]
[5] getproperty(obj::CLRObject, sym::Symbol)
@ DotNET C:\Users\<user>\.julia\packages\DotNET\Rx490\src\operators.jl:89
[6] top-level scope
@ .\REPL[15]:1
But trying after the error happend it works again:
julia> for i in 1:10000 GlobalDictInterface.Update("c1", "k$i", "v$i"^1000) end
Hi,
Thank you for the package.
I manage to assemblies from a dll following the example in the readme file. Would you be able to tell me how I can list the functions in that dll and call it?
Thank you
Best regards
I'm not really familiar with the internals of the package (nor .Net to be honest), but would it be possible to enable calling methods without specifyin optional arguments?
I copied and modified an MWE from a previous issue:
PS C:\Users\csert\Documents\temp\dotnettest> Add-Type -Namespace JuliaTest -Name Foo -MemberDefinition @'
>> public double Bar(double x, double y = 2)
>> {
>> return y*x;
>> }
>> '@ -OutputAssembly Example.dll
Calling from julia:
julia> using DotNET
julia> asm=T"System.Reflection.Assembly".LoadFrom("Example.dll")
System.Reflection.RuntimeAssembly("Example, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")
julia> Foo=asm.GetType("JuliaTest.Foo")
JuliaTest.Foo
julia> foo = Foo.new()
JuliaTest.Foo("JuliaTest.Foo")
julia> foo.Bar(3.14, 2)
6.28
julia> foo.Bar(3.14, 3)
9.42
julia> foo.Bar(3.14)
ERROR: CLRException: System.MissingMethodException: Method 'JuliaTest.Foo.Bar' not found.
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at CLRBridge.Meta.InvokeMember(IntPtr type, String name, BindingFlags bindingFlags, IntPtr binder, IntPtr target, IntPtr[] providedArgs, UInt32 argCount, IntPtr& exception)
Stacktrace:
[1] track_and_throw(exhandle::UInt64)
@ DotNET.CLRBridge C:\Users\csert\.julia\packages\DotNET\Rx490\src\CLRBridge.jl:46
[2] InvokeMember(type::UInt64, name::String, bindingFlags::UInt32, binder::Int64, target::UInt64, providedArgs::Vector{UInt64})
@ DotNET.CLRBridge C:\Users\csert\.julia\packages\DotNET\Rx490\src\CLRBridge.jl:325
[3] invokemember(flags::UInt32, type::CLRObject, this::CLRObject, name::Symbol, args::Float64)
@ DotNET C:\Users\csert\.julia\packages\DotNET\Rx490\src\marshalling.jl:83
[4] invokemember(type::CLRObject, this::CLRObject, name::Symbol, args::Float64)
@ DotNET C:\Users\csert\.julia\packages\DotNET\Rx490\src\marshalling.jl:94
[5] (::DotNET.PendingInvocation)(args::Float64)
@ DotNET C:\Users\csert\.julia\packages\DotNET\Rx490\src\operators.jl:19
[6] top-level scope
@ REPL[7]:1
With Julia v1.3.1, DotNET.jl v0.1.0, and .NET Core 3.1.1
using DotNET
then press down backspace on the REPL
Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: UNKNOWN at 0x66982697 -- jl_makecontext at /cygdrive/d/buildbot/worker/package_win64/build/src/support/cygdrive/d/buildbot/worker/package_win64/build/src/support\win32_ucontext.c:69
in expression starting at REPL[1]:0
jl_makecontext at /cygdrive/d/buildbot/worker/package_win64/build/src/support/cygdrive/d/buildbot/worker/package_win64/build/src/support\win32_ucontext.c:49
jl_alloc_fiber at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\task.c:695 [inlined]
ctx_switch at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\task.c:252
jl_switchto at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\task.c:376
try_yieldto at .\task.jl:602
wait at .\task.jl:668
wait at .\condition.jl:106
wait_readnb at .\stream.jl:355
eof at .\stream.jl:48
jfptr_eof_13155.clone_1 at C:\Users\jr\AppData\Local\Julia-1.3.1\lib\julia\sys.dll (unknown line)
_jl_invoke at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2135 [inlined]
jl_apply_generic at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2305
eof at .\io.jl:361
_jl_invoke at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2135 [inlined]
jl_apply_generic at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2305
match_input at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\REPL\src\LineEdit.jl:1342
match_input at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\REPL\src\LineEdit.jl:1342
_jl_invoke at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2135 [inlined]
jl_apply_generic at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2305
prompt! at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\REPL\src\LineEdit.jl:2390
run_interface at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\REPL\src\LineEdit.jl:2301
_jl_invoke at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2135 [inlined]
jl_apply_generic at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2305
run_frontend at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\REPL\src\REPL.jl:1045
run_repl at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.3\REPL\src\REPL.jl:201
_jl_invoke at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2135 [inlined]
jl_apply_generic at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2305
#770 at .\client.jl:382
jfptr_#770_7946.clone_1 at C:\Users\jr\AppData\Local\Julia-1.3.1\lib\julia\sys.dll (unknown line)
_jl_invoke at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2135 [inlined]
jl_apply_generic at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2305
jl_apply at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\julia.h:1631 [inlined]
jl_f__apply at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\builtins.c:627
jl_f__apply_latest at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\builtins.c:665
#invokelatest#1 at .\essentials.jl:709 [inlined]
invokelatest at .\essentials.jl:708 [inlined]
run_main_repl at .\client.jl:366
exec_options at .\client.jl:304
_start at .\client.jl:460
jfptr__start_2086.clone_1 at C:\Users\jr\AppData\Local\Julia-1.3.1\lib\julia\sys.dll (unknown line)
_jl_invoke at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2135 [inlined]
jl_apply_generic at /cygdrive/d/buildbot/worker/package_win64/build/src/cygdrive/d/buildbot/worker/package_win64/build/src\gf.c:2305
unknown function (ip: 00000000004017DD)
unknown function (ip: 0000000000401BC5)
unknown function (ip: 00000000004013DE)
unknown function (ip: 000000000040151A)
BaseThreadInitThunk at C:\Windows\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
Allocations: 24032118 (Pool: 24020372; Big: 11746); GC: 26
I've been trying to use ODBC.jl to efficiently load data from my local computer onto a MS SQL Server. I am able to load data but it goes row-by-row so is not efficient. I haven't found any way to do a bulk insert using ODBC.jl. But I am aware of the SqlBulkCopy class in C#, although I do not know C# myself. Could the DotNET.jl package be used to do bulk insert to SQL Server by using the SqlBulkCopy class?
I downloaded .NET SDK 7.0 and I tried to reference the System.Data.SqlClient shown in the example code in the link above but I don't know what the right name should be for the "mscorlib" shown below.
julia> SqlClient = T"System.Data.SqlClient, mscorlib"
Any thoughts on what the right name is?
I also tried to do the reflection assembly approach. I searched my computer for System.Data.SqlClient.dll and found that several programs I have installed have a copy of this file so I pointed to one (installed by SSMS) and that loaded okay.
julia> T"System.Reflection.Assembly".LoadFrom(raw".....link to System.Data.SqlClient.dll...")
However, when I try to reference any of the functions shown in the example code for SqlBulkCopy in the link above I get errors.
Am I on the right track here or way off base? I apologize if I'm way off, but I am interested in trying to figure out how to efficiently load data into SQL Server from my local computer using Julia (maybe with the help of C# :-)! Appreciate any help/thoughts.
How can I export The CLRObject
s? They seem to work fine in the same module.
chengd@6ab5c36e4fce:/workspaces/jl$ julia --project=.
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.7.2 (2022-02-06)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using DotNET
julia> # Termstructure
CLRtermstructure = T"System.Reflection.Assembly".LoadFrom(raw"/workspaces/fe/src/Termstructure/bin/Debug/net6.0/Termstructure.dll")
System.Reflection.RuntimeAssembly("Termstructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")
julia> CLRBrent = T"Termstructure.Zbrent, Termstructure"
Termstructure.Zbrent
julia> CLRBrent.new()
Termstructure.Zbrent("Termstructure.Zbrent")
Once they are imported into another module, I see errors like:
chengd@6ab5c36e4fce:/workspaces/jl$ julia --project=.
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.7.2 (2022-02-06)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> import EngTestWrapper
julia> EngTestWrapper.CLRtermstructure
Error showing value of type DotNET.CLRBridge.CLRObject:
ERROR: UndefRefError: access to undefined reference
Stacktrace:
[1] unsafe_string(bstr::DotNET.BStr)
@ DotNET ~/.julia/packages/DotNET/Rx490/src/typedef.jl:74
[2] GetString
@ ~/.julia/packages/DotNET/Rx490/src/CLRBridge.jl:167 [inlined]
[3] string
@ ~/.julia/packages/DotNET/Rx490/src/CLRBridge.jl:28 [inlined]
[4] show(io::IOContext{Base.TTY}, x::DotNET.CLRBridge.CLRObject)
@ DotNET ~/.julia/packages/DotNET/Rx490/src/reflection.jl:11
[5] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, x::DotNET.CLRBridge.CLRObject)
@ Base.Multimedia ./multimedia.jl:47
[6] (::REPL.var"#43#44"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
@ REPL /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:266
[7] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:510
[8] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
@ REPL /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:259
[9] display(d::REPL.REPLDisplay, x::Any)
@ REPL /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:271
[10] display(x::Any)
@ Base.Multimedia ./multimedia.jl:328
[11] #invokelatest#2
@ ./essentials.jl:716 [inlined]
[12] invokelatest
@ ./essentials.jl:714 [inlined]
[13] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
@ REPL /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:293
[14] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
@ REPL /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:277
[15] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:510
[16] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
@ REPL /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:275
[17] (::REPL.var"#do_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
@ REPL /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:846
[18] #invokelatest#2
@ ./essentials.jl:716 [inlined]
[19] invokelatest
@ ./essentials.jl:714 [inlined]
[20] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
@ REPL.LineEdit /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/LineEdit.jl:2493
[21] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
@ REPL /julia-1.7.2/share/julia/stdlib/v1.7/REPL/src/REPL.jl:1232
[22] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
@ REPL ./task.jl:423
Thank you!
Please provide a example of how to access "System.Windows.Forms"
OS -is- Windows 10 (x86_64-w64-mingw32)
Julia Version 1.6.2 -and- LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
dotnet --version >> 5.0.302
Project.toml [5091b313] DotNET v0.1.2 https://github.com/azurefx/DotNET.jl#master
Hi,
Are there any plans to add .NET Framework support in the future? In particular I am interested in versions 4.7/4.8.
Is Framework not supported because it is not really cross-platform compatible and woud mainly work on windows? Or does it simply need some work to get it working? If so and since you've already done all this great work to support .NET Core, do you know what specifically is missing to support the Framework as well.
Would be nice to have a list of what is missing to make this happen.
It seems System.Double is currently not supported. I have a class that returns a 2D double matrix (System.Double[,]) that I would like to retrieve in Julia. Is this currently possible or does It need to be added to the package?
I have been having trouble using external assemblies. Following the readme I have tried the following:
using DotNET
reader = T"System.Reflection.Assembly".LoadFrom(raw"/Users/n.t.wamsley/Projects/Julia_Testing/ThermoFisher.CommonCore.RawFileReader.dll")
Which returns
System.Reflection.RuntimeAssembly("ThermoFisher.CommonCore.RawFileReader, Version=5.0.0.88, Culture=neutral, PublicKeyToken=1aef06afb5abd953")
How can I use methods and types from this library? For example in the RawFileReader library,
there is an attribute 'RawFileReaderAdapter' with a method 'FileFactory'. I would like to do something like
rawFile = RawFileReaderAdapter.FileFactory(filename)
rawFile then has methods I could call to return data from the file.
The problem is that if I enter the following
rawfilereaderadapter = reader.GetType("ThermoFisher.CommonCore.RawFileReader.RawFileReaderAdapter", true, true)
filefactory = rawfilereaderadapter.GetMethod("FileFactory")
filefactory.ReturnType
filefactory.ReturnTypeCustomAttributes
I get
ThermoFisher.CommonCore.RawFileReader.RawFileReaderAdapter
System.Reflection.RuntimeMethodInfo("ThermoFisher.CommonCore.Data.Interfaces.IRawDataExtended FileFactory(System.String)")
ThermoFisher.CommonCore.Data.Interfaces.IRawDataExtended
System.Reflection.RuntimeParameterInfo("ThermoFisher.CommonCore.Data.Interfaces.IRawDataExtended")
respectively. Now I need to invoke the FileFactory method.
julia> filepath = convert(CLRObject, "/Users/n.t.wamsley/Projects/SAGE_TESTING/MA4358_FFPE_HPVpos_01_071522.raw")
julia> rawfile = filefactory.Invoke("", [filepath])
ThermoFisher.CommonCore.RawFileReader.RawFileAccess("ThermoFisher.CommonCore.RawFileReader.RawFileAccess")
julia> rawfile.IsOpen
false
rawfile.IsOpen should be returning true. I have verified that the file path is correct. So I suspect I am passing methods incorrectly. I wasn't sure if you had any ideas about what I could be doing wrong?
Here is a snippet from the .xml file describing the types and methods defined in the dll
<member name="T:ThermoFisher.CommonCore.RawFileReader.RawFileReaderAdapter">
<summary>
This static class contains factories to open raw files
</summary>
</member>
<member name="M:ThermoFisher.CommonCore.RawFileReader.RawFileReaderAdapter.FileFactory(System.String)">
<summary>
Create an IRawDataExtended interface to read data from a raw file
</summary>
<param name="fileName">File to open</param>
<returns>Interface to read data from file</returns>
</member>
Hello,
I am trying to use an external library called Kinesis from Thorlabs.
I can access the library but I run into an error because the software cannot find PresentationFramework
using DotNET
T"System.Reflection.Assembly".LoadFrom("C:\\Program Files\\Thorlabs\\Kinesis\\Thorlabs.MotionControl.DeviceManagerCLI.dll")
T"Thorlabs.MotionControl.DeviceManagerCLI.DeviceManagerCLI, Thorlabs.MotionControl.DeviceManagerCLI".BuildDeviceList()
serial_number = collect(T"Thorlabs.MotionControl.DeviceManagerCLI.DeviceManagerCLI, Thorlabs.MotionControl.DeviceManagerCLI".GetDeviceList())
dcservoCLI = T"System.Reflection.Assembly".LoadFrom("C:\\Program Files\\Thorlabs\\Kinesis\\Thorlabs.MotionControl.KCube.DCServoCLI.dll") [""]
@show serial_number # serial_number = ["27000577"]
kcube = dcservoCLI.GetType("Thorlabs.MotionControl.KCube.DCServoCLI.KCubeDCServo")
aux = convert(CLRObject, serial_number[1])
create = kcube.CreateKCubeDCServo(aux)
I get the following error:
ERROR: CLRException: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.IO.FileNotFoundException: Could not load file or assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at System.ModuleHandle.ResolveType(QCallModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctorWithParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
at Thorlabs.MotionControl.PrivateInternal.Settings.DeviceConfigurationManager..ctor()
at Thorlabs.MotionControl.PrivateInternal.Settings.DeviceConfigurationManager.get_Instance()
at Thorlabs.MotionControl.DeviceManagerCLI.DeviceConfigurationManager..ctor()
at Thorlabs.MotionControl.DeviceManagerCLI.DeviceConfigurationManager.get_Instance()
at Thorlabs.MotionControl.KCube.DCServoCLI.KCubeDCServo.InitializeDevice(String serialNo)
at Thorlabs.MotionControl.KCube.DCServoCLI.KCubeDCServo.CreateKCubeDCServo(String serialNo)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
at CLRBridge.Meta.InvokeMember(IntPtr type, String name, BindingFlags bindingFlags, IntPtr binder, IntPtr target, IntPtr[] providedArgs, UInt32 argCount, IntPtr& exception)
Stacktrace:
[1] track_and_throw(exhandle::UInt64)
@ DotNET.CLRBridge C:\Users\marquesd-admin\.julia\packages\DotNET\Rx490\src\CLRBridge.jl:46
[2] InvokeMember(type::UInt64, name::String, bindingFlags::UInt32, binder::Int64, target::UInt64, providedArgs::Vector{UInt64})
@ DotNET.CLRBridge C:\Users\marquesd-admin\.julia\packages\DotNET\Rx490\src\CLRBridge.jl:325
[3] invokemember(flags::UInt32, type::CLRObject, this::CLRObject, name::Symbol, args::CLRObject)
@ DotNET C:\Users\marquesd-admin\.julia\packages\DotNET\Rx490\src\marshalling.jl:83
[4] invokemember
@ C:\Users\marquesd-admin\.julia\packages\DotNET\Rx490\src\marshalling.jl:94 [inlined]
[5] (::DotNET.PendingInvocation)(args::CLRObject)
@ DotNET C:\Users\marquesd-admin\.julia\packages\DotNET\Rx490\src\operators.jl:19
[6] top-level scope
@ c:\Users\marquesd-admin\OneDrive - University of Birmingham\julia\dotNETKinesis.jl:13
Thanks
DotNET never crashes when I use it in the terminal but it does when I use it in VSCode.
To reproduce the issue just type using DotNET
in the julia REPL in VSCode (windows).
Linked issue julia-vscode/julia-vscode#1777
I am not sure whether the issue is coming from vscode or DotNET.
Thank you
If I try the following
myassembly = T"System.Reflection.Assembly".LoadFrom(dllfile)
myclass = T"MyAssebmly.MyClass, myassembly ".new()
myclass.StringProperty = "test"
I get the error:
ERROR: type CLRObject has no field StringProperty
Is there another way I can assign class properties?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.