Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 07, 2013 09:40 AM by kelewang
Dec 24, 2012 12:48 AM|LINK
I am using a label printing software named CodeSoft in my asp.net app thru COM Interop. Codesoft provides a function called CopyImageToFile which can be used to generate a BMP file for lable print preview effect. when i use this funtion in windows form app,
it works and can generated the BMP file containing the correct label variables' values. but when i use this funtion in asp.net, i watched that it can generate the bmp file, but the label variables's values doen't show. for example, i designed a label and created
one form variable named "VarPartCode", in C# code, i assign value "1245-783-TS" to it. Calling CopyImageToFile in windows form app works with the "1245-783-TS" string correctly showed on the generated BMP file. However, Calling it from asp.net can generate
BMP file but showed blank which should have shown "1245-783-TS" as windows form app did. I used processmonitor to track what happened, but find no clue. the code is same on windows app or asp.net app.
ApplicationClass raw = new ApplicationClass();
LabelManager2.Application lbl = raw as Application;
lbl.Visible = true;
lbl.Documents.Open(this.Server.MapPath(".") + "/pp.lab", false);
Document doc = lbl.ActiveDocument;
doc.Variables.Item("VarPartCode").Value = "1245-783-TS";
lbl.ActiveDocument.CopyImageToFile(24, "BMP", 0, 100, this.Server.MapPath(".") + "/test"); //output test.BMP
lbl = null;
thanks in advance for your any help!
Dec 26, 2012 07:26 AM|LINK
However, Calling it from asp.net can generate BMP file but showed blank which should have shown "1245-783-TS" as windows form app did.
Have you debug your code and see whether there is any exception which is thrown out?
Dec 26, 2012 07:31 AM|LINK
However, Calling it from asp.net can generate BMP file but showed blank which should have shown "1245-783-TS" as windows form app did. I
According to your description, it is hard to say what is the main issue. In order to resolve your issue, could you simply your project and upload it to skydrive? Then provide the link. I want to test locally and try to find the main issue.
Dec 27, 2012 12:16 AM|LINK
Hi, mitaGreen. thanks for ur help. No exception thrown.
Dec 27, 2012 12:22 AM|LINK
Hi Catherine, thank u for ur help. I can simply this web app, but it referenced codesoft 7's API which is not my homegrowned. I am not sure whether u have codesoft 7 installed on your computer in order to test locally?
Dec 27, 2012 07:07 AM|LINK
According to your description, the lable printing component is COM based and you're calling it in .NET app (either winform or ASP.NET) via managed interop wrapper.
For COM component, it is possible that the component is originally created as a STA (single thread apartment) one which is only intended to use in GUI applications (like winform, WPF, etc...). ASP.NET webform and webservice (also WCF) applications are multi-threading
hosting enviornment, so using STA COM component will cause problem. Therefore, I'd suggest you try contacting the component developer or provider of the "label printing" component to confirm this .
Dec 30, 2012 12:07 PM|LINK
thank u, Steven. I am trying to contact Codesoft's technical support team, waiting for their response. meanwhile, can the type libray of it expose whether it is as STA or as MTA? so i can find some clues while i am waiting. I have searched over the web,
found there is hardly material talking about integrating between asp.net and codesoft.
because I can use the codesoft in windows form app, Initially i thout it maybe related with security, the asp.net default process account network service or ASPNET doen't have enough privilidges, so i tried asp.net impersonation to simulating privilidged
user including administrator of IIS server according the following Microsoft KB article
and Serviced Components techs, but no luck.
thank you anyway, Steven.
Dec 31, 2012 02:52 AM|LINK
The following KB article has explained the threading model of COM component in detail.
#INFO: Descriptions and Workings of OLE Threading Models
And for in-proc COM component (loaded as DLL in calling application), you can check its threading model in the system registry table (find the node of the printing component under "HKEY_CLASSES_ROOT\CLSID".
See the "Marking the Supported-threading Model of In-Proc Servers" section of the above KB article for detailed information.
Jan 05, 2013 07:51 AM|LINK
Hi Steven. I followed your instructions but could not find its threading model. I saw three subkeys under the corresponding HKEY_CLASSES_ROOT\CLSID ,one is InProcessHandler32 and the value is ole32.dll ,one is localserver and the value is the full path to
the component's exe file, the third one is progId and the value is lppx2.application. I launched dcomcnfg.exe and found it's application type is local server under Dcom configuration node.
Jan 07, 2013 02:03 AM|LINK
ok, this morning I found when i view the page in the VS2008, it worked and generated the wanted BMP file.(via solution explorer window->web project->view this page in browser) but it didn't work after i deployed this web app to my iis5.1 server and browsed
it from the iis server. same codes! and the same DCOM configurations for lppa.exe COM application (the label design&printing components) ...
I used processmonitor to track the process info. found that when I viewed the page from VS, asp.net development server process named "WebDev.WebServer.EXE" was launched with my currently logged in computer account, when I deployed to iis, aspnet_wp.exe
was launched with account ASPNET, Initially i think it may be related to the account difference, so i changed my asp.net process identity to the same account as my currently logged in computer account via change machine.config but still no luck.
what something important i am missing? please help me, I nearly pull my hair out~