?
Solved

WIA VB.net Issue

Posted on 2010-11-10
2
Medium Priority
?
1,525 Views
Last Modified: 2012-06-27
Below are two code chunks.  The first is a VB6 program I wrote years ago that created multipage TIFs, the second is the VB.net program I am currently writing.  They look similar and from all of the research I have done whould work the same.  However I am getting the attached error.  Please advise.

Thanks,

Dustin

Here is the exception dump from VS:

System.Runtime.InteropServices.COMException was unhandled
  ErrorCode=-2147467259
  Message="Error HRESULT E_FAIL has been returned from a call to a COM component."
  Source="Interop.WIA"
  StackTrace:
       at WIA.ImageProcessClass.Apply(ImageFile Source)    at CDS_ImageEdit_vb.Form1.Form1_Load(Object sender, EventArgs e) in \\casnas1\sales\Walls\Visual Studio 2008\Projects\CDS ImageEdit_vb\CDS ImageEdit_vb\Form1.vb:line 25    at System.EventHandler.Invoke(Object sender, EventArgs e)    at System.Windows.Forms.Form.OnLoad(EventArgs e)    at System.Windows.Forms.Form.OnCreateControl()    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)    at System.Windows.Forms.Control.CreateControl()    at System.Windows.Forms.Control.WmShowWindow(Message& m)    at System.Windows.Forms.Control.WndProc(Message& m)    at System.Windows.Forms.ScrollableControl.WndProc(Message& m)    at System.Windows.Forms.ContainerControl.WndProc(Message& m)    at System.Windows.Forms.Form.WmShowWindow(Message& m)    at System.Windows.Forms.Form.WndProc(Message& m)    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)    at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)    at System.Windows.Forms.Control.SetVisibleCore(Boolean value)    at System.Windows.Forms.Form.SetVisibleCore(Boolean value)    at System.Windows.Forms.Control.set_Visible(Boolean value)    at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)    at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)    at System.Windows.Forms.Application.Run(ApplicationContext context)    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()    at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)    at CDS_ImageEdit_vb.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)    at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)    at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)    at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()    at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)    at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)    at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

VB6 CODE

Page1.LoadFile ccdDataHold(intCounter).strCCDPath1
Page2.LoadFile ccdDataHold(intCounter).strCCDPath2
Page3.LoadFile ccdDataHold(intCounter).strCCDPath3

IP.Filters.Add IP.FilterInfos("Frame").FilterID
Set IP.Filters(IP.Filters.Count).Properties("ImageFile") = Page2

IP.Filters.Add IP.FilterInfos("Frame").FilterID
Set IP.Filters(IP.Filters.Count).Properties("ImageFile") = Page3

IP.Filters.Add IP.FilterInfos("Convert").FilterID
IP.Filters(IP.Filters.Count).Properties("FormatID") = wiaFormatTIFF

Set Page1 = IP.Apply(Page1)
Page1.SaveFile "J:\VOID\" & ccdDataHold(intCounter).strCCDNameHold & ".tif"
intCounter = intCounter + 1

IP.Filters.Remove (1)
IP.Filters.Remove (1)
IP.Filters.Remove (1)


NEW VB.NET CODE

Page1.LoadFile ccdDataHold(intCounter).strCCDPath1
Page2.LoadFile ccdDataHold(intCounter).strCCDPath2
Page3.LoadFile ccdDataHold(intCounter).strCCDPath3

IP.Filters.Add IP.FilterInfos("Frame").FilterID
Set IP.Filters(IP.Filters.Count).Properties("ImageFile") = Page2

IP.Filters.Add IP.FilterInfos("Frame").FilterID
Set IP.Filters(IP.Filters.Count).Properties("ImageFile") = Page3

IP.Filters.Add IP.FilterInfos("Convert").FilterID
IP.Filters(IP.Filters.Count).Properties("FormatID") = wiaFormatTIFF

Set Page1 = IP.Apply(Page1)
Page1.SaveFile "J:\VOID\" & ccdDataHold(intCounter).strCCDNameHold & ".tif"
intCounter = intCounter + 1

IP.Filters.Remove (1)
IP.Filters.Remove (1)
IP.Filters.Remove (1)

Open in new window

Error.JPG
0
Comment
Question by:casnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:casnet
ID: 34104724
I am an idiot, this is the "NEW VB.NET CODE", sorry about that.

Dustin
Dim IPThread As New WIA.ImageProcess
        Dim Page1 As New WIA.ImageFile
        Dim Page2 As New WIA.ImageFile
        Dim Page3 As New WIA.ImageFile

        IPThread.Filters.Add(IPThread.FilterInfos("Frame").FilterID)

        Page1.LoadFile("C:\test\image1.tif")
        Page2.LoadFile("C:\test\image2.tif")
        Page3.LoadFile("C:\test\image3.tif")

        IPThread.Filters.Add(IPThread.FilterInfos("Frame").FilterID)
        IPThread.Filters(IPThread.Filters.Count).Properties("ImageFile").Value = Page2

        IPThread.Filters.Add(IPThread.FilterInfos("Frame").FilterID)
        IPThread.Filters(IPThread.Filters.Count).Properties("ImageFile").Value = Page3

        IPThread.Filters.Add(IPThread.FilterInfos("Convert").FilterID)
        IPThread.Filters(IPThread.Filters.Count).Properties("FormatID").Value = WIA.FormatID.wiaFormatJPEG

        Page1 = IPThread.Apply(Page1)
        Page1.SaveFile("C:\test\NewImage.tif")

        IPThread.Filters.Remove(1)
        IPThread.Filters.Remove(1)

        Application.DoEvents()

Open in new window

0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 34219704
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When converting a physical machine to a virtual machine using VMware vCenter Converter Standalone or vCenter Converter Enterprise, if an adapter type is not selected during the initial customization the resulting virtual machine may contain an IDE d…
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Teach the user how to rename, unmount, delete and upgrade VMFS datastores. Open vSphere Web Client: Rename VMFS and NFS datastores: Upgrade VMFS-3 volume to VMFS-5: Unmount VMFS datastore: Delete a VMFS datastore:
Teach the user how to configure vSphere clusters to support the VMware FT feature Open vSphere Web Client: Verify vSphere HA is enabled: Verify netowrking for vMotion and FT Logging is in place or create it: Turn On FT for a virtual machine: Verify …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question