All posts by rogue lj

SAP:Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘SAPbobsCOM.ICompany’

SAP Business One DI API

I kept getting the above error when attempting to generate documents on a thread other than the main thread. Here’s the error message in full:

Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘SAPbobsCOM.ICompany’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{3BA8DAED-5B33-4CE4-A4B8-B4308D86E524}’ failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
 
[quads id=1]

Turns out that running the following command on the client machine did the trick:

C:\SAP\SAP Business One DI API\DI API 88>regsvr32 SAPbobsCOM88.dll

What was weird here was that previous calls to the COM object on the main thread work fine. Any subsequent calls on a different thread threw the exception.

Incidentally, I have also spotted this error when using some 3rd party (and SAP – Certified) add-ons. In all cases, the above DLL registration command resolved the issue. Your mileage may vary, however.

For more information on the SAP Business One DI API, check out the following link over at the SBO website:

http://scn.sap.com/docs/DOC-7722

DMX Lighting Project

DMX Lighting

I came across some RGB LED’s the other day on oomlout (http://www.oomlout.co.uk/5mm-rgb-leds-super-flux-x3-p-203.html) and wondered what I could create with them. Having been a light jock in the past I decided I’d like to create my own little lighting show (to be possibly used as part of a larger project in around 12 months time… watch this space). I secured 12 for the price of £9.72 including delivery and they turned up within a couple of days.

I quickly set to work mounting them on their own little PCB with current limiting resistors & header.

From RGB / DMX Lighting Project

The plan is to drive them with an Arduino, MAX485 receiver to handle DMX interface duties & PWM Shield (from Practical Maker : http://www.practicalmaker.com). Here’s the test code to check the LED’s, and my soldering skills. Notice i’m using PWM pins 9,10 & 11 for each colour:

int redLedPin = 11;
int greenLedPin = 10;
int blueLedPin  = 9;  

void setup()  {
} 

void loop()  { 

  // All values are inverted. We'll need to deal with this later on.

    // Red
      analogWrite(redLedPin, 1);
      analogWrite(greenLedPin, 255);
      analogWrite(blueLedPin, 255);
      delay(300);                            

    // Green
      analogWrite(redLedPin, 255);
      analogWrite(greenLedPin, 1);
      analogWrite(blueLedPin, 255);
      delay(300);     

    // Blue
      analogWrite(redLedPin, 255);
      analogWrite(greenLedPin, 255);
      analogWrite(blueLedPin, 1);
      delay(300);       

}

Here’s a quick video of the test in action. You can tell that the LED is quite bright, as it’s saturating the image.

 

Here’s some slow shutter pics I took of the LED in action:

 

From RGB / DMX Lighting Project
From RGB / DMX Lighting Project

I think the next stage is to encase the PCB’s in either hot melt glue or sillicone sealant, to afford them a little protection. Next up will be testing with the PWM shield, as soon as it turns up.

I’ll be using Q Light Controller (http://sourceforge.net/projects/qlc/), and an Enttec Open DMX USB Interface (http://www.enttec.com/index.php?main_menu=Products&pn=70303&show=description) to control my little show.

 

Update 09-11-2011:

I covered the top and bottom of the PCB’s with hot melt glue. It’s not perfect, but I’m not going for IP68 😉

From Instant Upload

 

Update 17-11-2011:

The MAX485 Transceiver chips arrived – in a GIANT box I might add – so I got busy soldering them into a piece of stripboard (that was a little oversized…) and wired them to the Arduino PCB. With a little code, and help, from http://blog.wingedvictorydesign.com/2009/03/20/receive-dmx-512-with-an-arduino/, I got the second part of the project up and running, namely receiving DMX. At the moment I’m just outputting to the serial console . But eventually the DMX values will be piped along to the LED’s via the PWM Shield, as and when it turns up.

As the code from the blog above has been released under the WTFPL license (yeah, I had to look it up: http://sam.zoy.org/wtfpl/) I’ll be posting the finished code, but at this moment in time it’s pretty pointless due to the fact that I haven’t changed much from the original source.

Thanks to Max Pierson of Winged Victory Design for the help here – go visit his site, it’s been pretty useful for my project www.wingedvictorydesign.com

Sharepoint File Upload via VB.NET

I recently had reason to upload a lot of files to Sharepoint 2010. Unfortunately the Upload item in the menu would only allow me to do this in batches of 100.  Fortunately however, you can do this from code.

    Public Function UploadToSharepoint(ByVal localFile As String, ByVal remoteFilename As String, spUrl As String, username As String, password As String, domain As String) As Byte()

        ' Ensure that we've got a valid URL.
        If Not spUrl.EndsWith("/") Then spUrl &= "/"

        ' Build the remote url, escape spaces and replace backslashes.
        Dim rfURL As String = String.Format("{0}{1}", spUrl, remoteFilename).Replace(" ", "%20").Replace("\", "/")

        ' Create a webclient.
        Dim wc As New WebClient
        wc.Credentials = New System.Net.NetworkCredential(username, password, domain)

        ' Attempt the upload.
        Try
            Using s As New System.IO.FileStream(localFile, IO.FileMode.Open, IO.FileAccess.Read)
                Using reader As New System.IO.BinaryReader(s)
                    UploadToSharepoint = wc.UploadData(rfURL, "PUT", reader.ReadBytes(CInt(s.Length)))
                End Using
            End Using

        Catch ex As Exception
            UploadToSharepoint = Nothing

        End Try

    End Function