- UID
- 1
- 积分
- 15892
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
ObjectARX Technical Newsletter - March 2000
This document is part of ObjectARX Newsletter Archive
/Note: Have you missed a Newsletter issue? Visit our Newsletter archive at
the following URL:/
http://adn.autodesk.com/techsupp/docs/newsletters.htm
Dear ObjectARX developer,
Table of Content
================
1. ARX/DBX dependencies loading problem in AutoCAD and in general.
2. AutoCAD 2000 defect when implementing an MFC document template in
the AutoCAD application.
3. New and Updated Solutions
1. ARX/DBX dependencies loading problem in AutoCAD and in general.
------------------------------------------------------------------
One of the problem you may have when developing an ARX/DBX application
which is composed in several modules, or which uses other DLLs, is that
you may get the following annoying message "MyApplication.arx cannot find
a dll or other file that it needs.". This message can appear in applications
other than AutoCAD, but in AutoCAD you would also see the following on the
command line: "AcRxDynamicLinker failed to load 'XXX.arx'".
The first message is generated from the OS, while the second is generated
from the AutoCAD kernel. AutoCAD is using the ::LoadLibrary() Win32 API to
load an ARX/DBX application in its kernel, but if ::LoadLibrary() fails to
load the application because a dependency is not found, AutoCAD cannot
determine why this operation failed, in this case ::LoadLibrary() just
returns a NULL value. This is why the AutoCAD message is not really clear
compared to the one generated by the OS. What do you need to do in order
for your application loads properly in AutoCAD? The solution is simple but
not always easy to apply. The rule is that the OS needs to find your DLL,
so you need to make sure that your DLL is in the OS 'Search Path'
(not necessary the AutoCAD 'Search Path' which is a different thing).
So where? You have 2 standard options here. Either you put your DLLs into
an existing folder which is already in the OS Search Path
(i.e. "C:\Program Files\Common files\Autodesk Shared'), or you add your
application folder to the path variable. This last option requires that
you modify the OS settings during installation.
A third option is available to you as well and is explained in the
solution below.
Delay-loading .DBX modules from .ARX - no more Windows path grief!
Question:
I have an ObjectARX User Interface (.ARX) module which has dependency on
an ObjectDBX Object Enabler (.DBX) module. I link the .ARX with the .DBX's
import library (.LIB). The .DBX demand-loads correctly on proxy detection,
but the .ARX will not demand-load on command invocation. I get the
following error. MyApplication.arx cannot find a dll or other file that it
needs. If I add the location of the .DBX to the Windows system path or
install it into C:\Program Files\Common Files\Autodesk Shared then it works
fine, but I want to avoid that.
Answer:
There is a mechanism available in Visual C++ 6 called "delay loading". This
mechanism allows you to link to a library via the standard DLL linking
mechanism, but to delay its initialization until required.
To specify that your .ARX delay-loads your .DBX, edit your .ARX project's
linker settings:
1) Add the following library to the "Object/library modules" list:
delayimp.lib
2) Specify this setting (manually) in the "Project Options" text-box:
/delayload:"MyDbxModule.dbx"
You will now be able to demand-load both the .ARX module and the .DBX
without being constrained by the Windows system path. You will need to
load the DBX application programmatically from the ARX application for
this technique to work - use either acrxLoadModule() or
acrxDynamicLinker->loadModule().
Be warned that there are some limitations to this method, such as not
being able to access data directly in the .DBX module, but these are
all documented clearly on MSDN.
2. AutoCAD 2000 defect when implementing an MFC document template in
-----------------------------------------------------------------
the AutoCAD application.
------------------------
Since AutoCAD r13, the AutoCAD Window environment was based on the
MFC MDI feature. However, in AutoCAD r13 it was not possible to
create new MFC document template into the AutoCAD environment since
AutoCAD r13 was statically linked with MFC. With AutoCAD r14 which
uses MFC Shared DLLs, it was possible and therefore possible to
create a new MFC document template to have a multiple document
application user interface. Unfortunately, the AutoCAD 2000 shipping
release has a defect which prevents this from work properly. The problem
shows-up whenever you close a DWG file when another document type is
taking the focus, or (but less important) if your document view do not
implement the OnPaint() method. In you do not implement the workaround
below, AutoCAD will crash immediately with an 'Unhandled Exception Error'
and you will not be able to save your modified DWG.
The solution to fix this particular problem is to implement an
AcApDocManagerReactor::documentToBeDestroyed() reactor notification
as follows:
void AsdkT098MDIBUGFix::documentToBeDestroyed(AcApDocument* pDocToDestroy) {
//----- In case there is no more DWG document opened
//----- there is no other choice than
//----- closing all other MFC documents.
//----- These 2 lines force a close of all document of a specific
//----- MFC document template
//----- represented by 'pDocTemplate' to save & close silently.
if ( acDocManager->documentCount () == 1 )
pDocTemplate->CloseAllDocuments (TRUE) ;
//----- The lines below will insure that the document taking
//----- the focus will be an DWG document.
AcApDocumentIterator *pi =acDocManager->newAcApDocumentIterator () ;
while ( !pi->done () ) {
if ( pi->document () == pDocToDestroy ) {
POSITION pos =pi->document ()->cDoc
()->GetFirstViewPosition () ;
CView *pView =pi->document ()->cDoc ()->GetNextView
(pos) ;
while ( acedGetAcadFrame ()->MDIGetActive () !=
pView->GetParent () )
acedGetAcadFrame ()->MDINext () ;
break ;
}
pi->step () ;
}
delete pi ;
}
Also you document CView class must implement 'OnPaint()'.
3. New and Updated Solutions
----------------------------
New and updated solutions are available at:
http://adn.autodesk.com/techsupp/adnkb/whatsnew1.htm
or
http://adn.autodesk.com/techsupp/adnkb/whatsnew2.htm
-----------------------------------------------------------------------------
To subscribe or unsubscribe, go to
http://adn.autodesk.com/techsupp/docs/newsletters.htm
-----------------------------------------------------------------------------
You received this message as a result of your registration
on the ADN List Server subscription page. If you no longer wish
to receive these messages, read the next section, How to use this
mailing list.
How to use this mailing list:
You may unsubscribe from this e-mail newsletter, or subscribe to
a variety of other informative e-mail newsletters, by returning
to the ADN List Server subscription page at
http://adn.autodesk.com/techsupp/docs/newsletters.htm
and changing your subscription preferences.
Alternatively, from the subscribed account you can send an e-mail to
<Majordomo-partnersys@autodesk.com> with the following command in the
body of your email message:
unsubscribe <list-name>
----------------------------------------------------------------------
Autodesk Developer Network (ADN) information and events:
For information on all ADN topics, please visit:
http://www.autodesk.com/adn
----------------------------------------------------------------------
THIS DOCUMENT IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY. The
information contained in this document represents the current view of
Autodesk Inc. on the issues discussed as of the date of publication.
Because Autodesk must respond to change in market conditions, it
should not be interpreted to be a commitment on the part of Autodesk
and Autodesk cannot guarantee the accuracy of any information
presented after the date of publication.
INFORMATION PROVIDED IN THIS DOCUMENT IS PROVIDED 'AS IS' WITHOUT
WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND FREEDOM FROM INFRINGEMENT.
The user assumes the entire risk as to the accuracy and the use of
this document. This document may be copied and distributed subject to
the following conditions:
1. All text must be copied without modification and all pages must
be included
2. All copies must contain Autodesk's copyright notice and any other
notices provided therein
3. This document may not be distributed for profit |
|