I've been attempting to connect to iTunes using C# programming language. The process involves creating a dll in C# and running it with TypeScript through the Overwolf API.
Here's what I've done so far:
Generated a .dll file
I utilized the iTunesLib library based on this resource. Apologies for the Japanese article reference.
I set up a ClassLibrary project in Visual Studio and tested it within a Windows Forms application, which proved successful.
Next, I compiled the ClassLibrary and obtained a .dll file.
namespace MyNamespace{
public class MyClass {
public void myFunction() {
iTunesLib.iTunesAppClass iTunesApp = new iTunesLib.iTunesAppClass();
// do something with iTunesApp ....
}
}
}
Invoking C# function in Typescript
overwolf.extensions.current.getExtraObject("myNamespace", (result) => {
if (result.success) {
pluginInstance = result.object;
pluginInstance.myFunction(); // Calling the C# function
}
}
Error Analysis
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 upon deploying the application
Where MyNamespace.MyClass.myFunction()
Although it worked flawlessly in the Windows Form Application, why does it encounter issues when built into a dll? The problem seems to be related to the iTunesLib component.