例外:未处理CFItemNotFound,在当前存储中找不到项目[PreviewPNG] [英] Exceptions: CFItemNotFound was unhandled,Cannot find item [PreviewPNG] within the current storage

查看:316
本文介绍了例外:未处理CFItemNotFound,在当前存储中找不到项目[PreviewPNG]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是C#WinForm开发的新手. 我有一个预览SolidWorks(CAD软件)零件的图片框,
但是此代码无法查看大文件.例如,我可以顺利预览1,684k文件.但是,当我尝试预览3165k文件时,弹出以下EXCEPTION消息.
我不知道我是否清楚表达自己的意思,但是如果您还有其他问题,请随时问我.我可以将代码发送给您进行调试.
干杯!

--------------------我的C#WinForm代码-------------------------- ------

Hi there, I am new to C# WinForm development.
I have a picturebox to preview solidworks(a CAD software) parts,
but this code cannot view the large-size files. For example, I can preview a 1,684k file smoothly. However, when I was trying to preview a 3,165k file the following EXCEPTION message poped up.
I don''t know whether I express myself clearly, but please feel free to ask me if you have further questions. I can send my code to you for debugging.
Cheers!

--------------------My C# WinForm Code--------------------------------

private void Preview_Click(object sender, EventArgs e)
{

    textBox3.Text = dataGridView1.SelectedCells[3].Value.ToString();
    string STORAGE_NAME = textBox3.Text;
    //Get the entity of file with nodes
    CompoundFile cf = new CompoundFile(STORAGE_NAME);
    //Get desired node
    CFStream st = cf.RootStorage.GetStream("PreviewPNG");
    //Convert: stream-array of bytes-to memory-to picturebox
    byte[] buffer = st.GetData();
    var ms = new MemoryStream(buffer.ToArray());
    pictureBox1.Image = Image.FromStream(ms);

}



--------------------异常详细信息---------------------------- ----



--------------------Exception Details--------------------------------

OpenMcdf.CFItemNotFound was unhandled
  Message=Cannot find item [PreviewPNG] within the current storage
  Source=OpenMcdf
  StackTrace:
       at OpenMcdf.CFStorage.GetStream(String streamName)
       at CustomisedDesign.Form1.Preview_Click(Object sender, EventArgs e) in C:\Users\Bomiao\Documents\Visual Studio 2010\Projects\CustomisedDesign\CustomisedDesign\Form1.cs:line 519
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.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.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       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(Form mainForm)
       at CustomisedDesign.Program.Main() in C:\Users\Bomiao\Documents\Visual Studio 2010\Projects\CustomisedDesign\CustomisedDesign\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

推荐答案

似乎是OpenMCDF抛出的.您使用的是最新版本吗?您是否尝试过使用其他方法(也许可以使用7zip作为存档打开文件并找到该流)或其他MCDF阅读器来提取PreviewPNG流? OpenMCDF可能有错误,但是您可能碰巧具有比OpenMCDF读取的新/不同的文件格式.

我建议您将其源代码包含在项目中,并逐步进入其中以查看其中的内容.

关于格式: http://www.openoffice.org/sc/compdocfileformat.pdf [ ^ ]
可能也有用: http://help.solidworks.com/2010/English/api/swdocmgrapi/SolidWorks.Interop.swdocumentmgr~SolidWorks.Interop.swdocumentmgr.ISwDMSheet2~GetPreviewPNGBitmapBytes.html [
It seems to be thrown by OpenMCDF. Are you using the latest version of it? Have you tried to extract the PreviewPNG stream with other methods (you might be able to open the file with 7zip as archive, and find the stream), or with other MCDF readers? The OpenMCDF might have an error, but you might happen to have a newer/different file format, than OpenMCDF reads.

I suggest you to include the source of it in your project, and step into it to see what''s there.

About the format: http://www.openoffice.org/sc/compdocfileformat.pdf[^]
Might be also usefull: http://help.solidworks.com/2010/English/api/swdocmgrapi/SolidWorks.Interop.swdocumentmgr~SolidWorks.Interop.swdocumentmgr.ISwDMSheet2~GetPreviewPNGBitmapBytes.html[^]


这篇关于例外:未处理CFItemNotFound,在当前存储中找不到项目[PreviewPNG]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆