几何尺寸与公差论坛

 找回密码
 注册
查看: 791|回复: 0

【转帖】rouble extracting png bitmap preview picture in asp.net application

[复制链接]
发表于 2009-4-12 22:42:18 | 显示全部楼层 |阅读模式
trouble extracting png / bitmap preview picture in asp.net application
hello,
using the document manager api i have successfully created a vb.net console app that extracts the png preview using the getpreviewpngbitmap() method.
but...
when i use this same method in a asp.net app, i get the following when i call the method:
catastrophic failure (exception from hresult: 0x8000ffff (e_unexpected))
i see the warnings in the api help documentation saying that this function may not work with asp.net, and sure enough i can't get it to work.
has anyone run up against this problem? any suggestions?
thanks in advance....code below:
dim sdocfilename as string = "c:\documents and settings\bcavan\my documents\visual studio 2008\websites\website1\upload\extraction\037-001-876.sldprt"
dim sextractdir as string = "c:\documents and settings\bcavan\my documents\visual studio 2008\websites\website1\upload\extraction"
dim swclassfact as swdmclassfactory
dim swdocmgr as swdmapplication
dim swdoc as swdmdocument10
dim swcfgmgr as swdmconfigurationmgr
dim vcfgnamearr as object
dim vcfgname as object
dim swcfg as swdmconfiguration7
dim ppreview as ipicturedisp
dim ppreview2 as ipicturedisp
dim ndoctype as long
dim nretval as long
dim i as long
dim bret as boolean
ndoctype = swdmdocumenttype.swdmdocumentpart
swclassfact = createobject("swdocumentmgr.swdmclassfactory")
swdocmgr = swclassfact.getapplication("my code")
swdoc = swdocmgr.getdocument(sdocfilename, ndoctype, false, nretval)
swdoc = ctype(swdoc, swdmdocument10)
ppreview2 = swdoc.getpreviewpngbitmap(nretval) ' error occurs here
dim myimage2 as image = ipicturetoimage(ppreview2)
dim myfilename = path.getfilenamewithoutextension(swdoc.fullname)
myimage2.save(sextractdir & "\" & myfilename & ".png")
you won't get it to work with asp.net unfortunately. it is due to access permissions on iis.
you may be able to tweak the server but i have not bothered to try it yet.
i think i can answer my own question now...
swdmdocument11::getpreviewbitmapbytes
...it gives me a byte array, which i then successfully wrote to a file...
cool!
ooooo. never knew about that one, wonder if that works with all out of process applications.
how did you get this to work? looking at your code you don't check to see if swdoc is null (nothing) before attempting to get the preview. i have been struggling with this, and i figured it was a permission problem. however, giving 'everyone' (including iusr, network service, etc) permissions on the director i am attempting to pull the document from doesn't work.
how did you overcome that barry?
just a note to anyone else looking for a solution to this; the fix was simple. all that was required was setting allowreadonly to true for getdocument(). should have known!
quick
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 18:29 , Processed in 0.035809 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表