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";
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.
Best wishes,
Please mark the replies as answers if they help or unmark if not.
Feedback to us
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?
love your parents and your friends as you love yourself!
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 .
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 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.
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.
thanks anyway.
love your parents and your friends as you love yourself!
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~
love your parents and your friends as you love yourself!
kelewang
Member
106 Points
34 Posts
codesoft copyimagetofile API doesn't take effect but succeeds in windows form app
Dec 24, 2012 12:48 AM|LINK
Hi folks,
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.Documents.CloseAll(false); lbl.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(lbl); lbl = null;thanks in advance for your any help!
mitaGreen
Member
188 Points
34 Posts
Re: codesoft copyimagetofile API doesn't take effect but succeeds in windows form app
Dec 26, 2012 07:26 AM|LINK
Hi,
Have you debug your code and see whether there is any exception which is thrown out?
Catherine Sh...
All-Star
23382 Points
2490 Posts
Microsoft
Re: codesoft copyimagetofile API doesn't take effect but succeeds in windows form app
Dec 26, 2012 07:31 AM|LINK
Hi,
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.
Best wishes,
Feedback to us
Develop and promote your apps in Windows Store
kelewang
Member
106 Points
34 Posts
Re: codesoft copyimagetofile API doesn't take effect but succeeds in windows form app
Dec 27, 2012 12:16 AM|LINK
Hi, mitaGreen. thanks for ur help. No exception thrown.
kelewang
Member
106 Points
34 Posts
Re: codesoft copyimagetofile API doesn't take effect but succeeds in windows form app
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?
Steven Cheng...
Contributor
4199 Points
548 Posts
Microsoft
Moderator
Re: codesoft copyimagetofile API doesn't take effect but succeeds in windows form app
Dec 27, 2012 07:07 AM|LINK
Hi Kelewang,
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 .
Feedback to us
Microsoft One Code Framework
kelewang
Member
106 Points
34 Posts
Re: codesoft copyimagetofile API doesn't take effect but succeeds in windows form app
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
http://support.microsoft.com/kb/306158/en-us
and Serviced Components techs, but no luck.
thank you anyway, Steven.
Steven Cheng...
Contributor
4199 Points
548 Posts
Microsoft
Moderator
Re: codesoft copyimagetofile API doesn't take effect but succeeds in windows form app
Dec 31, 2012 02:52 AM|LINK
Hi kelewang,
The following KB article has explained the threading model of COM component in detail.
#INFO: Descriptions and Workings of OLE Threading Models http://support.microsoft.com/kb/150777
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.
Feedback to us
Microsoft One Code Framework
kelewang
Member
106 Points
34 Posts
Re: codesoft copyimagetofile API doesn't take effect but succeeds in windows form app
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.
thanks anyway.
kelewang
Member
106 Points
34 Posts
Re: codesoft copyimagetofile API doesn't take effect but succeeds in windows form app
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~