Automation issue with the Autocad 2015

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
We wrote a library in c++ (com application) which calls AutoCAD API to retrieve document related information.This library is called by below 2 applications 1. Desktop application. 2. Asp Web application AutoCAD 2006 works fine for both scenarios. We are in the process of upgrading to 2015, but AutoCAD 2015 doesn't work for asp web applications. It fails while creating "AutoCAD.Application.20". Error we get is "Server execution failed" Is there anything else to be configured inorder for AutoCAD work with web applications.
Library code:
STDMETHODIMP AutocadStart::StartAutocad()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
ofstream outFile;
outFile.open("C:\\temp\\outFile1.txt");
// TODO: Add your implementation code here
m_error = "Starting Autocad";
outFile << "Creating Autocad application" << std::endl;
COleException oOleException;
BOOL bRes;
bRes = m_oApplication.CreateDispatch( "AutoCAD.Application", &oOleException );
if ( !bRes )
{
char szError[256];
char szUserName[256];
unsigned long ulSize;
ulSize = sizeof(szUserName);
GetUserName( szUserName, &ulSize );
oOleException.GetErrorMessage( szError, sizeof(szError) );
m_error = "Starting Autodesk AutoCAD failed. User=";
m_error += CString(szUserName);
m_error += CString(szError);
m_bStarted = FALSE;
outFile << m_error << std::endl;
}
else
{
m_oApplication.SetVisible(true);
m_bStarted = TRUE;
m_error = "Started Autocad";
outFile << "Success" << std::endl;
}
outFile.close();
return S_OK;
}
STDMETHODIMP AutocadStart::ErrorMessage(BSTR *pVal)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
*pVal = m_error.AllocSysString();
return S_OK;
}
STDMETHODIMP AutocadStart::Shutdown()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
if(m_bStarted == TRUE)
{
m_oApplication.Quit();
m_oApplication.ReleaseDispatch();
m_bStarted = FALSE;
}
return S_OK;
}
Console test app code:
int main(int argc, char* argv[])
{
try
{
AUTOCADAPITESTLib::IAutocadStartPtr pInput= NULL;
HRESULT hr=CoInitialize(NULL);
hr= CoCreateInstance(__uuidof(AUTOCADAPITESTLib::AutocadStart), NULL, CLSCTX_ALL, __uuidof(AUTOCADAPITESTLib::IAutocadStart), (void**)&pInput);
if(FAILED(hr))
{
_com_error testhr(hr);
cout<< testhr.ErrorMessage()<< std::endl;
}
else
{
pInput->StartAutocad();
string error = pInput->ErrorMessage();
pInput->Shutdown();
}
}
catch(...)
{
}
CoUninitialize();
return 0;
}
ASP code to test:
<!DOCTYPE html>
<html>
<body>
<%
Set objReg=CreateObject("AutocadAPITest.AutocadStart")
objReg.StartAutocad()
response.write(objReg.ErrorMessage())
objReg.Shutdown()
%>
</body>
</html>
Directly calling Autocad from asp:
<!DOCTYPE html>
<html>
<body>
<%
Set objReg=CreateObject("AutoCAD.Application.20")
response.write(objReg.GetVersion())
objReg.Quit()
%>
</body>
</html>
On IIS application runs with the admin permissios