INTERACT FORUM
Windows => Plug-in Development => Topic started by: PhDSM on September 10, 2014, 08:18:42 am
-
Hello,
I've upgraded from Version 17 and I have an Automation process that doesn't work anymore.
Did you change something in MJFilesAutomation * Search(string strSearch).
I can access the server but I always get "0 found" for all of my searches
Is there any change in Search string between version 17 and 20 ?
Thanks
-
It should work.
What if you search for a really simple string, like a?
-
it is a very basic one : Playlist="NeedInfoDB"
I 've try with other like Name="Let" and it is the same
Example of my code ( I call MCA fron VBA (Office))
Set MCA = GetObject(, "MediaJukebox Application")
Set MJVersion = MCA.getversion()
MJVersionSt = MJVersion.Version => Ok : it Shows 20.0.12
SearchString = "Name=""Let""" ' or Playlist=""NeedInfoDB"""
Set MJSchList = MCA.Search(SearchString)
NbFilePlayList = MJSchList.GetNumberFiles() => Doesn t work get 0 in all case instead of 59 or 22
Set MJCurList = MCA.GetCurPlaylist()
NbFileCurPlayList = MJCurList.GetNumberFiles() => Ok get the right number
The code worked well on MC-17
-
Just as a test search for a without quotes. Or even specify an empty search. Does that return matches?
-
Whatever I put I always get 0
I've changed Library and get same result.
-
I ve tried on another PC with Windows 7 and install MC 20. Same problem MCA.search always return nothing
I've also tried with a new library, still nothing.
If I load MC17, it works
-
I've tried a workaround as my search was to get a specific playlist.
So I get through all playlists to find mine.
Again, the program works in MC17 and not in MC20
Is there a problem with MC20 or in my programing ?
Set MJPlaylists = MCA.GetPlaylists()
MJNbPlaylists = MJPlaylists.GetNumberPlaylists()
Found = False
i = 0
Do
Set CurPLPtr = MJPlaylists.GetPlaylist(i)
If CurPLPtr.Name = "NeedInfoDB" Then Found = True
i = i + 1
Loop Until i = MJNbPlaylists - 1 Or Found
If Not trouve Then
MsgBox ("List NeedInfoDB not Found ")
End If
-
in my previous example
MJPlaylists.GetNumberPlaylists() works and returns the good number (299 in my case)
but MJPlaylists.GetPlaylist(i) returns nothing, whatever (i) is
-
Do you have any news about this issue ?
I've tried with :
- all recent version of MJ20 (up to 20.0.30),
- with Windows 8 & windows 7,
- 4 different PCs, with VBA from Office 2007, 2010. 2013
it works only If I use MC17, but I don't what you've changed since MC 17 ?
I still stuck with this issue.
After trying to move my list to the "Playing now" and accessing it thru .GetCurPlaylist() I get the good number of file but then the
.GetFile(i) doesn't work.
If you can't fix it , I will need to return to MC 17. Is there any tool to convert back MC20.0 library to MC17.
Regards
-
I just can't reproduce the issue. I wonder if there's some middleware on your computer that's standing in between MC and you? A virus checker or something?
-
What is strange is that some API works other don't and MC17 works with the same config.
I've also tried on 3 different hardwares
I've tries without the Antivirus, It doesn't change.
I don't know how to investigate further. My VBA apps was working well from MC11 up to MC17.
Is it the link between VBA and MC API that cause the problem?
Do you see any test that I can do ?
Regards
-
Is it the link between VBA and MC API that cause the problem?
I guess it's possible. Can you try a C++ example as a test?
-
I'm not very familiar with C or C++, however I develop a new little standalone program in VB2010 to test (my previous apps was in VBA for MS-Office).
I've tried on 2 different computers (one in Win 7 the other in Win 8.1).
The program is simple :
Get MC version, Get Number of Playlist, Get Number of Field
Do a Search of a string and display number of entries found
I run it on MC 17 and MC 20
On both computer on MC17
Get MC version => works ok
Get Number of Playlist => works ok
Get Number of Field => works ok
Do a Search of a string => works ok
On both computer on MC20
Get MC version => works ok
Get Number of Playlist => works ok
Get Number of Field => works ok
Do a Search of a string => always return 0
Attached a screen capture.
I can send you the exe and the source so you can try it on your instance of MC20 to see what happen.
I have also other quality issues with MC20 compared to MC 17, I will treat them in a separate thread
Thanks
-
I loaded the wrong file, here is the good screen capture
-
What does MJPlaylists.GetPlaylist(0) return?
Seems to be something to do with enumerations.
Also what Visual Studio Runtime versions do you have installed on your computer?
-
The result is strange :
CurPLPtr = MJPlaylists.GetPlaylist(0) works and I can access .name
but
Dim i As Integer
i = 0
CurPLPtr = MJPlaylists.GetPlaylist(i)
Fails : The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
on MC20 only
-
I've installed MC19 and MC 18 on a separate PC (Win 7)
and got the same issue, I looks like the problem starts with MC18.0.
-
what visual studio runtimes do you have on those computers?
Matt:
I remember there were some changes in the compiler used at various points. Anything between V17 and V20?
-
The COM API was broken in 18.0.90, as I mentioned here:
http://yabb.jriver.com/interact/index.php?topic=76147.msg516343#msg516343
This was part of the big last push to pull out Windows-specific code before the Mac version launched. If you'd like, the last version before these changes was 18.0.78. You can try that one and see if it fixes your issue.
The whole COM API was fixed though as of build 91, with a few other details tweaked in the builds afterwards. I've had no issues with it since then.
MCAutoQueue makes heavy use of an iterating Playlist system like the one you have there, though, and it works fine with current builds. I build it in Visual Studio 2012, though, and it is targeted at .NET 4.0.
-
I just checked through my code. I don't have anything that uses MJAutomation.Search() that I found in a brief look. However, I do have Playlist iteration code that does basically what you are trying to do here:
Set MJPlaylists = MCA.GetPlaylists()
MJNbPlaylists = MJPlaylists.GetNumberPlaylists()
Found = False
i = 0
Do
Set CurPLPtr = MJPlaylists.GetPlaylist(i)
If CurPLPtr.Name = "NeedInfoDB" Then Found = True
i = i + 1
Loop Until i = MJNbPlaylists - 1 Or Found
If Not trouve Then
MsgBox ("List NeedInfoDB not Found ")
End If
-
Code (in C#):
/// <summary>
/// Gets a sorted string-type list of all of the Playlist names currently in MC
/// </summary>
/// <returns>string-type List or null if it failed</returns>
public static List<string> GetMCPlaylistNames()
{
// Iterate through all of the Playlists in MC and build a list of all of their names
MediaCenter.IMJPlaylistsAutomation mcPlaylists = Instance.GetPlaylists();
// Check to see if it worked and if there are any playlists at all
if (mcPlaylists == null || mcPlaylists.GetNumberPlaylists() <= 0)
return null;
List<string> playlistNames = new List<string>();
for (int i = 0; i < mcPlaylists.GetNumberPlaylists(); i++)
{
// Check the Playlist's name against the one in settings
MediaCenter.IMJPlaylistAutomation currPlaylist = mcPlaylists.GetPlaylist(i);
string fullPlaylistPath;
if (currPlaylist.Path == "")
{
fullPlaylistPath = currPlaylist.Name;
}
else
{
fullPlaylistPath = currPlaylist.Path + "\\" + currPlaylist.Name;
}
playlistNames.Add(fullPlaylistPath);
}
playlistNames.Sort();
return playlistNames;
}
/// <summary>
/// Returns the IMJPlaylistAutomation object that we want for the given Playlist path
/// </summary>
/// <param name="playlistFullName"></param>
/// <returns>a IMJPlaylistAutomation object reference to the playlist request, or null if it failed</returns>
public static MediaCenter.IMJPlaylistAutomation GetPlaylist(string playlistFullName)
{
// Check to see if they sent us something silly
if (playlistFullName == "" || playlistFullName == null)
return null;
// Iterate through all of the Playlists in MC until you find the one we want
MediaCenter.IMJPlaylistsAutomation mcPlaylists = Instance.GetPlaylists();
// Check to see if it worked and if there are any playlists at all
if (mcPlaylists == null || mcPlaylists.GetNumberPlaylists() <= 0)
return null;
MediaCenter.IMJPlaylistAutomation currPlaylist = null;
bool success = false;
for (int i = 0; i < mcPlaylists.GetNumberPlaylists(); i++)
{
// Check the Playlist's name against the one in settings
currPlaylist = mcPlaylists.GetPlaylist(i);
string fullPlaylistPath;
if (currPlaylist.Path == "")
{
fullPlaylistPath = currPlaylist.Name;
}
else
{
fullPlaylistPath = currPlaylist.Path + "\\" + currPlaylist.Name;
}
success = fullPlaylistPath.Equals(playlistFullName, StringComparison.OrdinalIgnoreCase);
if (success) break;
}
// If we found it, return it, otherwise return null
if (success)
{
return currPlaylist;
}
else
{
return null;
}
}
That's old code, and some of the comments are a bit whacked (sorry), but it does work perfectly with the current build of MC20.
-
Oh yes, Glynor reminded me of something else to check. What version of .Net are you targeting?
-
One thing that also comes to mind here is Visual Basic. I'm not an expert as I use C# for the most part. That said I remember VB handling how values are passed between functions and COM. I think that is what is at play here, but for the life of me I can't remember the details.
I picked up on this thread because it rang a bell, but I just can't remember the details.
-
Also try this:
Dim i As UInteger
i = 0
CurPLPtr = MJPlaylists.GetPlaylist(i)
-
one more thing: You are rebuilding the COM wrapper for each version right? I.E. the MC20 version of the wrapper has to be created from the MC20 version of MC.
-
one more thing: You are rebuilding the COM wrapper for each version right? I.E. the MC20 version of the wrapper has to be created from the MC20 version of MC.
You don't need to do this with .NET, unless I misunderstand what you mean. My old compiled apps work fine with MC20.
It uses whichever copy is registered with COM, which is the last one launched (hence the UAC prompt).
-
I can test the Search() method from .NET 4.0 C# relatively easily. But it seems like he has other issues.
-
You don't need to do this with .NET, unless I misunderstand what you mean. My old compiled apps work fine with MC20.
It uses whichever copy is registered with COM, which is the last one launched (hence the UAC prompt).
I haven't used .net and com in quite some time so please correct me if I'm wrong. From what I remember you reference a dll file that contains the com interface and Visual Studio automatically creates an interop wrapper. You can either do the interop manually or use the one created. What I'm guessing may be happening is he is using MC 17 dll as a reference when "creating the wrapper". Something may have changed in the implementation between 17 and 18 that requires building the wrapper off of the newer version. Technically it should work providing nothing has changed, but there may be something that has broken the interface in between versions. Something to try at least...
-
I can test the Search() method from .NET 4.0 C# relatively easily. But it seems like he has other issues.
Can you try running the simple code he posted using VB? I think the issue may lie with VB as opposed to c#. Back in the day when I used to do lots of .Net I remember their being some differences when using interop with the 2.
-
I checked with UInterger instead of integer, it doesn't change.
Here is my test code in VB :
Sub TestMC(ByVal SearchStr As String)
'==============
Dim MCA, MJVersion, MJPlaylists, MJSchList, MJFields, CurPLPtr, CurFilePtr, FileList As Object
Dim i, MJNbPlaylists, NbFilePlayList As UInteger
Dim Trouve As Boolean
Dim PLName, FLName, LName As String
' First try to get an already running Mediacenter
On Error Resume Next
MCA = GetObject(, "MediaJukebox Application")
If Err.Number = 429 Then
'Then, create a new Mediacenter
On Error GoTo 0
MCA = CreateObject("MediaJukebox Application")
Else
If Err.Number <> 0 Then
MsgBox("Erreur chargement MediaCenter #" + CStr(Err.Number) + " / " + Err.Description)
End If
End If
On Error GoTo 0
MJVersion = MCA.getversion()
'Put version in the VBForm
Form1.Version.Text = MJVersion.Version
MJFields = MCA.getFields()
'Put NbField in the VBForm
Form1.NbField.Text = MJFields.GetNumberFields
MJPlaylists = MCA.GetPlaylists()
'Put NbPlaylist in the VBForm
Form1.NbPlaylist.Text = MJPlaylists.GetNumberPlaylists()
MJNbPlaylists = MJPlaylists.GetNumberPlaylists()
CurPLPtr = MJPlaylists.GetPlaylist(0)
PLName = CurPLPtr.Name
FileList = CurPLPtr.GetFiles()
NbFilePlayList = FileList.GetNumberFiles()
'check if GetFile works with 0
CurFilePtr = FileList.GetFile(0)
FLName = CurFilePtr.Name
'check if GetFile works with i = 0
i = 0
CurFilePtr = FileList.GetFile(i)
FLName = CurFilePtr.Name
'check if GetPlaylist works with 0
CurPLPtr = MJPlaylists.GetPlaylist(0)
LName = CurPLPtr.Name
'check if GetPlaylist works with i = 0
i = 0
Trouve = False
Do
CurPLPtr = MJPlaylists.GetPlaylist(i)
If CurPLPtr.Name = "NeedInfoDB" Then Trouve = True
i = i + 1
Loop Until i = MJNbPlaylists - 1 Or Trouve
MJSchList = MCA.Search(SearchStr)
'Put GetNumberFiles of Search in the VBForm
Form1.NbTrouve.Text = MJSchList.GetNumberFiles()
End Sub
-
There have been a lot of questions asked here. Can you please provide the answers so we can continue to help you.
Thanks
-
I haven't used .net and com in quite some time so please correct me if I'm wrong. From what I remember you reference a dll file that contains the com interface and Visual Studio automatically creates an interop wrapper. You can either do the interop manually or use the one created. What I'm guessing may be happening is he is using MC 17 dll as a reference when "creating the wrapper". Something may have changed in the implementation between 17 and 18 that requires building the wrapper off of the newer version. Technically it should work providing nothing has changed, but there may be something that has broken the interface in between versions. Something to try at least...
Kinda... With any version of MC I've programmed against (so, going way back) you don't reference against the DLL file directly. In fact, MC doesn't even include one. You reference against a TLB file, which is kind-of a "library descriptor" stub file.
This doesn't change. You can test it yourself if you want. Download an old version of my MCUtilities application pack, such as this one from July 2013 (http://yabb.jriver.com/interact/index.php?topic=81514.msg557059#msg557059), and try to run one of them using MC20 (which didn't exist when it was built).
I don't have time to test right now, but I'm 99% sure it'll still work (though, of course, bugs won't be fixed).
-
I don't have time to test right now, but I'm 99% sure it'll still work (though, of course, bugs won't be fixed).
Just tested, and yes, it works fine.
Now, it is possible, I suppose that the TLB file was broken in an incompatible way with MC 18.0.90. But you can download a zipped version of MCUtilities 1.0.2 (http://glynor.com/files/MCUtilities/MCUtilities-1020.zip) (built 07/05/2013) and it works just fine with the current MC 20.
-
Can you try running the simple code he posted using VB? I think the issue may lie with VB as opposed to c#. Back in the day when I used to do lots of .Net I remember their being some differences when using interop with the 2.
Yes. VB makes my eyes bleed though. I'll need to know how to set up my MC library to get an expected result. :P
-
There have been a lot of questions asked here. Can you please provide the answers so we can continue to help you.
+1
-
So, I made a Project in Visual Studio 2012 with the exact test code shown above (http://glynor.com/files/jriver/PhDSM-TempTest.zip), wired up to a simple form (like the one in the screenshot above). I fixed a few minor syntax errors (perhaps a difference in style between older and newer versions of VB), but otherwise it is exactly as originally coded.
I too am getting an exception when you try to use an Integer value with GetFile() or most other IMJAutomation methods that take integers. It does look odd. This works:
'check if GetFile works with 0
CurFilePtr = FileList.GetFile(0)
FLName = CurFilePtr.Name
This throws an exception:
'check if GetFile works with i = 0
i = 0
CurFilePtr = FileList.GetFile(i)
FLName = CurFilePtr.Name
It could be as simple as a casting issue. However, I don't see why you are doing all of this:
Dim MCA, MJVersion, MJPlaylists, MJSchList, MJFields, CurPLPtr, CurFilePtr, FileList As Object
Why are you defining those variables as "dumb" Objects? You should be using the IMJAutomation interfaces appropriate to the types, and then you'll actually get Intellisense to work, if nothing else. It makes it almost impossible to debug, and I don't know VB well enough (and am not otherwise motivated enough) to figure it out.
I can tell you that this class's (http://glynor.com/files/jriver/PhDSM-MCComConnector.zip) GetMC function works (in C#):
/// <summary>
/// Gets the MC Core Automation object
/// This is used ONLY by the Instance Property
/// </summary>
private static IMJAutomation GetMC()
{
// Run the connection timer
RunConnectionTimer();
// Get the MC Instance!
MCAutomation mcAutomation;
try
{
// Try to connect to a running instance of MC
mcAutomation = GetRunningMC();
}
catch (Exception e)
{
// Check the type of exception we got. Certain types can be handled.
switch (e.HResult)
{
case -2147221005:
{
throw new InvalidOperationException(
"MC isn't registered properly in COM. Reinstall the current version of Media Center.", e);
}
case -2147221021:
{
// Then the exception was "Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))"
// Which is what happens when MC isn't currently running.
ClassLogger.Info("No running instance of MC found.");
// Try to create an instance of MC instead
mcAutomation = LaunchMC();
}
break;
default:
{
// Then we don't know what the error was, so throw it.
throw;
}
}
}
return mcAutomation;
}
/// <summary>
/// This attempts to connect to an already running copy of MC.
/// </summary>
/// <returns>The MCAutomation instance for the connected copy of MC.</returns>
private static MCAutomation GetRunningMC()
{
ClassLogger.Info("Attempting to connect to running instance of MC.");
// Try to connect to a running instance of MC
var mcAutomation = (MCAutomation)Marshal.GetActiveObject("MediaJukebox Application");
if (ValidateInstance(mcAutomation))
{
// Kill the connection timer
ConnectionTimer.Enabled = false;
ClassLogger.Info("Successfully connected to Media Center.");
return mcAutomation;
}
else return null; // This will never get returned because ValidateInstance will throw an exception.
}
/// <summary>
/// This attempts to launch MC and returns the MCAutomation instance.
/// </summary>
/// <returns>The MCAutomation instance after launching.</returns>
private static MCAutomation LaunchMC()
{
ClassLogger.Info("Launching Media Center...");
try
{
var mcAutomation =
(MCAutomation) Activator.CreateInstance(Type.GetTypeFromProgID("MediaJukebox Application"));
if (ValidateInstance(mcAutomation))
{
// Kill the connection timer
ConnectionTimer.Enabled = false;
ClassLogger.Info("Successfully launched Media Center.");
LaunchedMC = true;
return mcAutomation;
}
else return null; // This will never get returned because ValidateInstance will throw an exception.
}
catch (Exception ex)
{
// Something terrible happened
ConnectionTimer.Enabled = false;
ClassLogger.Fatal("Launching MC Failed: {0}", ex.Message);
ClassLogger.Fatal(ex);
throw;
}
}
-
I think the issue is that MC internally doesn't use the same integer format as VB is defining the Integer variable (i in the example above). Probably using a Long or something else. But, because you are defining the COM objects all as "dumb" objects, the compiler can't figure it out and cast to the proper type for you, so it throws.
If you are going to use strongly typed variables (unlike in vbscript, for example) then I think you need to actually get the real interface from the MC object. My C# code does it well above, though I don't know how to convert that to VB anymore.
I know you can do it in VB. I have done it, but it is all very old stuff and I don't have it working or in my head anymore.
-
Let me summarize the situation
Context:
I'm an Early Adopter of MC starting with MediaJukeBox. Over 12 years of utilisation I build a 80000 entries database with Audio, Images and Video.
Since MJAutomation in 2008 I developped a link between an Excel Database (Movie database) and MC using VB for application (par of MS-Office)
Last summer I migrated to MC 20.0 from MC17 and since then without change my environment, I occured several problems.
One of them is the fact that my VBA apps doesn't work anymore. (I will start other threads with my other problems when I will have enough time)
Problem :
Within my VBA code the call to .search(string) always return 0 whatever string is.
Also calls to .Getfile(i) or .Getplaylist(i) fails (throw exception).
After check on my sider , code works ok with MC17 and fails witrh MC18, MC19, MC20.
Current situation :
From what I understand from previous messages, you change MJAutomation API with version 18.0.78 to pullout windows-specific code.
It seems that the new version of MJAutomation API works well with C++ but not with VB (VBA or VB2010 or VB2012)
Problem seems to be link with the parameters, or parameters type.
.Getfile(0) works but Getfile(i) with i=0 as Integer, Uinteger doesn't
That could also be the reason for .search but based on my testing .Search("let") or .Search(SearchString) with SearchString='Let' both returns 0.
What is different between old MJAutomation (up MC 18.0.78) and new MJAutomation (after MC 18.0.78) that make VB inoperative.
Final question :
How to make MJAutomation working from VB ?
I will seach on my side how to better define variable type to map MC object Model.
Thanks very much for your help
Phil
-
It's pretty much what I thought then. From memory VB interacts slightly different than C# when doing COM interop. It has to do with Varient types. Which you shouldn't be using anyway. You can use them, but it is poor form in a type safe language.
To start to fix your code you should use Option Strict. https://support.microsoft.com/kb/311329?wa=wsignin1.0
That will force all your variable to be strictly cast or the compiler will throw an error. That may be all you have to do to fix the issue.
-
Thanks for your answer.
After investigating, the Option Strict & Explicit , didn't change anything.
However after checking VB forums, I change the code to "force conversion" i.e. I coded the following way :
.GetFile( CInt(i) ) instead of .GetFile(i)
.Search( CStr("Playlist=""NeedInfoDB""") ) instead of .Search("Playlist=""NeedInfoDB""")
and it works !!!
Problem solved !
Thanks for your active support.
I will now investigate my others problems with MC20, sorry but you will hear from me again.
Cheers
Ph
-
Problem solved !
Wow, that's nice! Thanks for sharing what you've learned.
-
Yes that is good to hear. Just to recap VB doesn't handle type conversion the same as C#. What you ended up doing is explicitly casting to to native types, which fixes the issue.
I think you can also use Option Strict which enforces strict typing, but there must also be something else as this alone didn't work. I know you can do COM interop in VB without explicit casting. Can't remember how though.
You can also use the MarshalAs attribute to tell the compiler how to send the call to the COM object.
-
Quick question to conclude.
What is the internal type for Date like lastPlayed date ? .Set("Last Played", ??)
I've tried Int, Double, Long, none of them seems to work.
-
Yes that is good to hear. Just to recap VB doesn't handle type conversion the same as C#. What you ended up doing is explicitly casting to to native types, which fixes the issue.
I think you can also use Option Strict which enforces strict typing, but there must also be something else as this alone didn't work. I know you can do COM interop in VB without explicit casting. Can't remember how though.
You can also use the MarshalAs attribute to tell the compiler how to send the call to the COM object.
Yes. I'm glad to hear you straightened it out. I'm also glad I wasn't crazy and it was a casting issue.
You would almost certainly not have to cast explicitly if you marshaled the objects to strongly typed Interfaces instead of using generic objects. But, I don't know modern VB well enough to say for sure (the vast majority of my VB knowledge is from the 6.x days before .NET existed).
-
Quick question to conclude.
What is the internal type for Date like lastPlayed date ? .Set("Last Played", ??)
I've tried Int, Double, Long, none of them seems to work.
I don't know what the actual format of the number is, but they're stored in the database using a scheme identical to Excel's.
It would probably not be an integer, because there is a fractional part of the number (for the time).
-
Quick question to conclude.
What is the internal type for Date like lastPlayed date ? .Set("Last Played", ??)
I've tried Int, Double, Long, none of them seems to work.
I just want to make sure you turned on Option Strict and then changed all the variant data type to strongly typed ones. This should have worked. Implicitly casting calls is kludge not a fix. You wouldn't have to cast anything if that was done as far as I know.
-
Implicitly casting calls is kludge not a fix.
+1 (In a strongly-typed language like VB.NET anyway.)
You wouldn't have to cast anything if that was done as far as I know.
Yeah. I'm pretty much 99.9% sure it would work right. And, it would be obviously better because Intellisense would work too. In most cases, you don't even need all of those additional variables because you can do stuff right inline. So, this:
MJPlaylists = MCA.GetPlaylists()
'Put NbPlaylist in the VBForm
Form1.NbPlaylist.Text = MJPlaylists.GetNumberPlaylists()
MJNbPlaylists = MJPlaylists.GetNumberPlaylists()
CurPLPtr = MJPlaylists.GetPlaylist(0)
PLName = CurPLPtr.Name
FileList = CurPLPtr.GetFiles()
Becomes this:
Form1.NbPlaylist.Text = MCA.GetPlaylists().GetumberPlaylists()
PLName = MCA.GetPlaylists().GetPlaylist(0).Name
FileList = MCA.GetPlaylists().GetPlaylist(0).GetFiles()
etc...
If I'm motivated, I might whip up some general-purpose VB code that does the marshaling thing right and put it in the Wiki. If you're writing a compiled application and not a script I don't know why you'd pick VB over C# anyway, but to each their own I guess.
But I don't know, because remembering all I forgot about VB will make my brain hurt for a while. :P
-
Thanks for this feedback.
In fact I use VBA which is the Macro Language of MS-Office, because I just develop a link between MC and an Excel movie Database.
I agree that VB would not be the best choice for a stand alone application, but to link MC with MS-Office VBA is the easiest.
I agree with you about the intermediate variables. There were not in the original code, I just put then in debugging to see step by step what MC is returning.
So far I've been able to adapt my code to MC20. For you information regarding the dates, it works if I pass them as strings.
Now i will concentrated to fix my Communication issue between my MC20 server MC 20 remote computer that occurs since MC17 to MC20 migration (see : New Problems since migration fom MC17 to MC20 thread)
Thanks again for all your support
-
In fact I use VBA which is the Macro Language of MS-Office, because I just develop a link between MC and an Excel movie Database.
I agree that VB would not be the best choice for a stand alone application, but to link MC with MS-Office VBA is the easiest.
Yeah, sorry... I got that. When I said what I said it wasn't intended to criticize your choice here.
At the very least (this is clunky) you should be able to cast the MCA variable to a proper IMJAutomation object after you get it.
-
Ahhh that is the part I kept missing. I thought you were using VB.Net instead of VBA. Now I see why you have to "marshall by hand".
You can also use VB.Net and Visual Studio with Office instead of VBA. It does take more work initially, but is soooooo much nicer to work with doing the development and debugging. Bit of a learning curve to go that route though.
-
Thanks for the advice :)
-
Oh! I assumed he was using Visual Studio! You can do VBA from within Visual Studio, and since VS2013 is free for those kinds of uses now, there's absolutely no reason not to.
If you're hand-writing this in a text editor like an animal, just go download yourself a copy of Visual Studio. More info:
http://blogs.msdn.com/b/somasegar/archive/2014/11/12/opening-up-visual-studio-and-net-to-every-developer-any-application-net-server-core-open-source-and-cross-platform-visual-studio-community-2013-and-preview-of-visual-studio-2015-and-net-2015.aspx
http://www.visualstudio.com/products/visual-studio-community-vs