I'm trying to access iTunes using C#. The steps are to write a dll in C# and execute it with TypeScript using Overwolf API.
What I did
Generate .dll
I introduced iTunesLib based on this. Sorry for the Japanese article..
I created a ClassLibrary project in Visual Studio and tested it in a Windows Forms application. This worked.
Then built ClassLibrary and generated a .dll file.
namespace MyNamespace{
public class MyClass {
public void myFunction() {
iTunesLib.iTunesAppClass iTunesApp = new iTunesLib.iTunesAppClass();
// do something with iTunesApp ....
}
}
}
Call C# function in Typescript
overwolf.extensions.current.getExtraObject("myNamespace", (result) => {
if (result.success) {
pluginInstance = result.object;
pluginInstance.myFunction(); // Call C# function
}
}
Error report
ERROR: Error: Failed to execute PauseITunes on AudioController with 0 arguments. details:
System.Reflection.TargetInvocationException: target threw an exception ---> System.IO.FileNotFoundException: Could not load file or assembly 'Interop.iTunesLib, Version=1.13.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies when deploying the application
Where MyNamespace.MyClass.myFunction()
It worked in Windows Form Application, but why does it stop working when I build it into a dll? The error seems to be occurring in the iTunesLib part.
As Heinz Siahaan said, I was able to solve the problem by placing interop.iTunesLib.dll
in the same hierarchy.
Thank you so much.