This is based on a recent post in the Main forum where a user wanted to set and increment a time variable. Thought I'd take a whack at the CLR TimeSpan... Got an error, so yet another chance to learn
;trying time span with WB and CLR
t = ObjectClrNew( "System.DateTime")
today = t.Now
Message("",today)
;get error Method Type Signature Not Interop Compatible
;h = ObjectType("I4",1)
;m = ObjectType("I4",0)
;s = ObjectType("I4",0)
;ts = ObjectClrNew( "System.TimeSpan",h,m,s)
;new= today.add(ts)
;Message("",new)
t=0
Exit
The 'more error info' message is poorly worded but it still says it all. It likely ain't gonna work in WinBatch. There aren't many of them but some of the 'System' FCL structures don't support being created using the CLR's native early bind COM API.
Quote from: td on January 24, 2014, 01:31:45 PM
The 'more error info' message is poorly worded but it still says it all. It likely ain't gonna work in WinBatch. There aren't many of them but some of the 'System' FCL structures don't support being created using the CLR's native early bind COM API.
Does this also apply to Plan-B's: i.e. leveraging through Powershell, or creating a .dll from C# code?
While I cannot answer with respect to PowerShell, I have created a couple of COM DLLs in C#, to enable me to import assembly properties into Microsoft Excel. To be sure, there are plenty of rules, limitations, and traps for the unwary, and the process is poorly documented, but it can be done.
Off the top of my head, two of the most important rules are the following.
- Static methods are unsupported.
- All objects must have a public default constructor that takes no arguments.
Quote from: stanl on January 25, 2014, 03:14:59 AM
Does this also apply to Plan-B's: i.e. leveraging through Powershell, or creating a .dll from C# code?
A simple C# cover assembly compiled using WinBatch would be one possible solution. However, since the problem can be easy solved in strait WIL without the assistance of the CLR, it appears to be overkill.
Quote from: td on January 25, 2014, 11:27:59 PM
Quote from: stanl on January 25, 2014, 03:14:59 AM
Does this also apply to Plan-B's: i.e. leveraging through Powershell, or creating a .dll from C# code?
A simple C# cover assembly compiled using WinBatch would be one possible solution. However, since the problem can be easy solved in strait WIL without the assistance of the CLR, it appears to be overkill.
I agree. Convert to OADate, and do all the maths you want.