Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, August 25, 2006 10:14:05 AM(UTC)

cmurphy  
cmurphy

Groups: Registered
Posts: 31


I'm converting code from version 13.0 to version 14.5. Old code was written by someone else:

public LTANNLib.LEADRasterAnnToolBarClass m_TheAnnToolbar = null;

private void ViewToolbar_Click(object sender, System.EventArgs e, string fileFullPath)
{
 LEAD.Drawing.Bitmap userBmp = new LEAD.Drawing.Bitmap(GetType(), "user.bmp");
 LTRASTERLib.LEADRasterFactoryClass factory = new LTRASTERLib.LEADRasterFactoryClass();
 object rasterObj = factory.CreateObject("LEADRaster.LEADRaster",
     "LEADTOOLS OCX Copyright (c) 1991-2001 LEAD Technologies, Inc.");
 LTRASTERLib.LEADRasterClass rasterTemp;
 try
 {
     rasterTemp = (LTRASTERLib.LEADRasterClass)rasterObj; //error here
     IntPtr hBitmap = userBmp.GetHbitmap();
     Graphics g = CreateGraphics();
     IntPtr hDC = g.GetHdc();
     rasterTemp.SetDDB(hDC.ToInt32(), hBitmap.ToInt32(), 0);
     g.ReleaseHdc(hDC);
     g.Dispose();
     DeleteObject(hBitmap);
     m_TheAnnToolbar.set_ButtonTool(m_TheAnnToolbar.ButtonCount,
         LTANNLib.AnnToolConstants.ANN_TOOL_USER_FIRST);
     m_TheAnnToolbar.set_ButtonBitmapUp(m_TheAnnToolbar.ButtonCount, rasterTemp.Bitmap);
     m_TheAnnToolbar.set_ButtonBitmapUp(m_TheAnnToolbar.ButtonCount, rasterTemp.Bitmap);
     m_TheAnnToolbar.set_ButtonBitmapDown(m_TheAnnToolbar.ButtonCount, rasterTemp.Bitmap);
     m_TheAnnToolbar.set_ButtonToolTipTextID(m_TheAnnToolbar.ButtonCount, -1);
     m_TheAnnToolbar.set_ButtonToolTipText(m_TheAnnToolbar.ButtonCount, "User Defined");
     m_TheAnnToolbar.ButtonCount++;
 }
 catch (System.Exception ex)
 {
  throw ex;
 }
}
[DllImport("gdi32")]
public static extern int DeleteObject(IntPtr hObject);

I've changed one line of code from:
LEAD.Drawing.Bitmap userBmp = new LEAD.Drawing.Bitmap(GetType(), "user.bmp");
To:
Bitmap userBmp = new Bitmap(GetType(), "user.bmp");

When I run it, it didn't error that line but it throw exception from:
rasterTemp = (LTRASTERLib.LEADRasterClass)rasterObj;

Here is an error detail:
Cannot create LeadRasterClass object window. ---> System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to class type 'LTRASTERLib.LEADRasterClass'. COM components that enter the CLR and do not support IProvideClassInfo or that do not have any interop assembly registered will be wrapped in the __ComObject type. Instances of this type cannot be cast to any other class; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
   at UserControl.ViewToolbar_Click(Object sender, EventArgs e, String fileFullPath)

I was unable to find information of LTRASTERLib.LEADRasterClass from help file. I don't know what is it.

1. Could you point me out where to look for in help file?

2. It was fine with version 13.0. Is there any additional/change that I should do for version 14.5?

Please help,

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, August 27, 2006 11:41:54 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

Please try to use the following code instead of your code:
+-----------------------------+
...
const String strLic = "LEADTOOLS OCX Copyright (c) 1991-2004 LEAD Technologies, Inc.";
LTRASTERLib.LEADRasterFactoryClass factory = new LTRASTERLib.LEADRasterFactoryClass(); LTRASTERLib.LEADRasterClass rasterTemp;
try
{
    rasterTemp = (LTRASTERLib.LEADRasterClass) factory.CreateObject("LEADRaster.LEADRaster.140", strLic);
...
+-----------------------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Monday, August 28, 2006 1:07:16 PM(UTC)

cmurphy  
cmurphy

Groups: Registered
Posts: 31


I've tried the code but it still throws same exception.

I've made a small project and I've got difference error:

System.Runtime.InteropServices.COMException (0x800401F3): Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))

at LTRASTERLib.LEADRasterFactoryClass.CreateObject(String pszClassID, String pszLic)

at DrawingPackageControl.DrawingUserControl.ViewToolbar_Click(Object sender, EventArgs e, String fileFullPath) in Q:\Development\test\DPControl\DPControl\MainControl.cs:line 284

--- End of inner exception stack trace ---

I've sent my test project to support@leadtools.com. Please use 2nd project to review and let me know.

Thanks,

 
#4 Posted : Wednesday, August 30, 2006 5:09:21 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello Chanthirar,

I tried several times to run your project but I faced a lot of problem because of the missing references.
However, I reproduced the problem on my side and solved it. Please try to use the following code in your project:
+-----------------------------+
form1.cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CSRasterCOM145
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            const String strLic = "LEADTOOLS OCX Copyright (c) 1991-2004 LEAD Technologies, Inc.";
            try
            {
                LTRASTERLib.LEADRasterFactoryClass factory = new LTRASTERLib.LEADRasterFactoryClass();
                LTRASTERLib.LEADRaster rasterTemp;
                rasterTemp = (LTRASTERLib.LEADRaster)factory.CreateObject("LEADRaster.LEADRaster.140", strLic);
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }
        }
    }
}
+-----------------------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.098 seconds.