Windows Develop Bookmark and Share   
 index > Windows Forms General > Microsoft Office Document Imaging Viewer control
 

Microsoft Office Document Imaging Viewer control

hai

I am using Microsoft Office Document Imaging Viewer control in my vb.net application (2005).I have to load the tiff images into this control. And i am keeping the path in a database table and, loads all the records into on datagridview control from this table.When i click one row in a grid the row should come to the edit mode (in seperate text box and its ok) .At the same time the image is loading in to one picture box control.If the user clicks the picture box it will open a new window which contains Microsoft Office Document Imaging Viewer control and loads the image ,selected inthe previouspicture box.And i colse the new window the open it again it says file sharing violation error .And i cannot open it again?????.

So that when ever loading the MODI contained window i am coping the tiff image from the original location to my application root folder. then from there i try to open the tiff image into MODI control .And when i am closing the new window i try to delete the image file which i copied to root foolder ,it say it is being used by another user .

So how can i load the file again and again to MODI control (tiff image file)

Dim _MODIDocument As MODI.Document = New MODI.Document()

_MODIDocument.Create(Environment.CurrentDirectory & sFile)

AxMiDocView1.Document = _MODIDocument

this is the error if i am doing

System.IO.IOException: The process cannot access the file 'C:\Laiju\ApplicationTif\ApplicationTif\bin\Debug\CR-2784.tiff' because it is being used by another process.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

at System.IO.File.Delete(String path)

at ApplicationTif.frmpreview.frmpreview_Load(Object sender, EventArgs e) in C:\Laiju\ApplicationTif\ApplicationTif\frmpreview.vb:line 18

laiju lal  Sunday, October 01, 2006 7:49 AM

It seems like Document Image View control is not releasing picture when the form is close, See there will be any method to unload the image from the control and call it in FormClosing or FormClose event handler on the formwhich is hosting the Document Imaging Viewer Control.

Please have a look, I really hope that there would be some function to unload the document. If you cannot find then please write back I'll test it on my own Machine.

Best Regards & Best of Luck,

RizwanSharp  Sunday, October 01, 2006 4:51 PM

I am having same problem . I am using Microsoft Office Document Imaging Viewer control in C# application which gives the same type of error - "File Sharing Violation". Is there a workaround for this?

private MODI.Document _MODIDocument = null;

private void Sample(string filename)

{

try

{

if (_MODIDocument != null)

{

_MODIDocument.Close(false);

_MODIDocument = null;

}

_filename = filename;

_MODIDocument = new MODI.Document();

_MODIDocument.Create(filename); //Error

axMiDocView1.Document = _MODIDocument;

axMiDocView1.Refresh();

}catch(System.Runtime.InteropServices.COMException ee)

{

MessageBox.Show(ee.Message);

}

}

eliteramesh  Wednesday, October 18, 2006 3:30 AM

Use the following code

Dim xMyDoc As MODICtl.Document

Set xMyDoc = New MODICtl.Document
xMyDoc.Create "c:\abc.tif"
MiDocView1.Document = xMyDoc

Moose74  Tuesday, May 08, 2007 10:37 AM
Moose74 wrote:

Use the following code

Dim xMyDoc As MODICtl.Document

Set xMyDoc = New MODICtl.Document
xMyDoc.Create "c:\abc.tif"
MiDocView1.Document = xMyDoc

I am using this code in VB 6.0 and I get an "IO error"

It errors on the xMyDoc.Create "c:\abc.tif"

Raminator74  Wednesday, May 23, 2007 1:40 PM

c:\abc.tiff with 2 "f" and it'll work

thanks for this help.

oufti _  Monday, March 17, 2008 12:22 PM
Hi All,

Just wanted to let you know that I was having this same problem. In my case I had a Ghost Script making a copy of the the file before my MODI routines worked on the file. The error is was getting was IO Error with no explanation other than that. I removed my Ghost Script routines and my MODI routines no longer errored out. To get around this I had the Ghost Scirpt routines refresh the state of the file after they had completed their processing.

This is the Ghost Script routine: (input.Refresh(); is the code that refreshes the file state)

private string ConvertSingleImage(string filename)

{

bool Converted = false;

//Setup the converter

converter.OutputToMultipleFile =

false;

converter.FirstPageToConvert = -1;

converter.LastPageToConvert = -1;

converter.FitPage =

true;

//converter.JPEGQuality = (int)numQuality.Value;

converter.OutputFormat =

FileExtentionDevice.tifflzw.ToString();

System.IO.

FileInfo input = new FileInfo(filename);

string output = string.Format("{0}\\{1}{2}", input.Directory, input.Name.Replace(".pdf",""), "." + fileExtension.tif.ToString());

//If the output file exist alrady be sure to add a random name at the end until is unique!

while (File.Exists(output))

{

output = output.Replace(

"." + fileExtension.tif.ToString(), string.Format("{1}{0}", "." + fileExtension.tif.ToString(), DateTime.Now.Ticks));

}

Converted = converter.Convert(input.FullName, output);

input.Refresh();

return output;

}

DrewHook  Thursday, September 10, 2009 11:26 PM
Hi,

Does _MODIDocument have a Dispose method ?

If so, can you call Dispose on it sometime prior to trying to delete the file ?
You may also need to set AxMiDocView1.Document = null as well.
Yort  Thursday, September 10, 2009 11:35 PM

You can use google to search for other answers

Custom Search

More Threads

• How to change theme of a software
• WebBrowser w/o cookies
• Printing Document in windows service
• copying one object to another,..
• Send data from one form to the other
• Replace Tokens in File?
• One menustrip many forms
• Changing DataGridView cell font style
• Focus in textBox
• Are there any issues with the Data Form Wizard