Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLRException: System.MissingMethodException with TagLibSharp dll #12

Closed
asasa137 opened this issue Oct 7, 2021 · 2 comments
Closed

Comments

@asasa137
Copy link

asasa137 commented Oct 7, 2021

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

@azurefx
Copy link
Owner

azurefx commented Oct 17, 2021

julia> T"TagLib.Tag, TagLibSharp".GetProperty("Year")
System.Reflection.RuntimePropertyInfo("UInt32 Year")

The property Year is of type System.UInt32 in CLR, which is mapped to UInt32 in Julia, while the literal 2010 is of type Int(32 or 64). When DotNET.jl tries to find the property with exact type info , an MissingMethodException is thrown. I admit that this mechanism needs to be improved in the future, and you can use UInt32(2010) as a workaround.

@asasa137
Copy link
Author

Thanks, it actually works !
Good to know what the error means.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants