几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-13, 11:50 AM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】how do i create an installer api projec

how do i create an installer api project??
hi,
i was developed api project on vb.net 2005 and addin on solidworks 2008. then i want to create setup file (.dll) for using that project on another computers. how do i create them? i try to using "setup wizard" to create an installer. it's don't work.
regard
shukree,
this will be covered in full in my next book. but yes setup project is what you need to start but it gets complicated with sw add-in registration and even more so when it comes to multi-platform and x64bit msi installers etc...
there are a few things that are easy to miss. this all assumes 32bit swx. as luke mentioned, it's different for 64bit since installers are platform specific.
1. use the setup project's registry settings to set the following key:
hkey_local_machine\software\solidworks\addins\{xxxxx}
you can find the guid in the swaddin code file at the top of the swaddin class definition.
the key shown above as {xxxxx} must be the guid for your dll.
2. inside that key, create two string values - one named title and the other description. this is what the user will see in the solidworks add-ins list.
3. using the project's registry settings, set the following key:
hkey_classes_root\clsid\{xxxxx}\inprocserver32
again, the {xxxxx} should be your dll's guid.
4. in the inprocserver32 key, create the following string values:
(default) value = "mscoree.dll"
class value = "yourassembly.swaddin"
*** the value must be your project's assembly name (find under my project, application, assembly name) and the name of your add-in class. for example, the template's add-in class is named "swaddin".
codebase value = "file:///[targetdir]yourassembly.dll"
*** yourassembly.dll is your dll name.
threadingmodel value = "both"
that should be enough to get it registered properly. if anyone sees anything i'm missing, please chime in.
mike spens
"automating solidworks using macros"
leap frog leap pad x64
there is a nice easy way to get your plugins to register and unregister themselves using the visual studio install project using an installer class.
i had a lot of problems getting installers to work when i first tried. you can add an install project to your solution and set it to register your addin with com and it does - except it does not excecute the custom register and unregister methods of your addin.
i didn't like the idea of having to manually create registry entries to be excecuted during install so a lot of searching on the web produced the following (assuming you started from the swaddin wizard) :
this works for 32bit windows xp, i haven't tried any other systems so maybe someone can try and let me know. also you may not be able to do this with visual studio express (i'm pretty sure you can't so don't spend too mucjh effort trying!), you might need to get standard or professional.
(1)
add an installer class to your addin project and paste in the following code:
imports system.componentmodel
imports system.configuration.install
imports system.runtime.interopservices
public class installer1
public sub new()
mybase.new()
'this call is required by the component designer.
initializecomponent()
'add initialization code after the call to initializecomponent
end sub
public overrides sub install(byval statesaver as system.collections.idictionary)
mybase.install(statesaver)
dim regsrv as new registrationservices
regsrv.registerassembly(mybase.gettype().assembly, assemblyregistrationflags.setcodebase)
end sub
public overrides sub uninstall(byval savedstate as system.collections.idictionary)
mybase.uninstall(savedstate)
dim regsrv as new registrationservices
regsrv.unregisterassembly(mybase.gettype().assembly)
end sub
end class
(2)
add an installer project to your solution:
file->add-> new project
poject type: setup and deployment
template: setup project
add your addins primary output as the source for the installer project:
right click your setup project and add project output
choose your addins primary output and confirm
select your addins primary output as the install and uninstall custom action:
right click your setup project
choose add->custom action
the custom actions tab will appear
right click the install folder and add you projects primary output
do the same for the uninstall folder
(3)
look for the primay output of your setup project in the solution explorer
click on it and look in the properties change its register flag to vspdadonotregister
the installer class will do this for us.
build your installer class and voila all done for you much easier and will call the following code of your addin:
public shared sub registerfunction(byval t as type)
and
public shared sub unregisterfunction(byval t as type)
hope this is helpful.
cheers
tom mulder
regards
tom mulder.
compac nw8440
intel core 2 t7400 2.16ghz
ati mobility firegl v5200
solidworks 2008 sp4.0
windows xp professional sp2
edited: 08/08/2008 at 09:34 pm by thomas mulder
mike,
i followed the steps you described above, the the addin seems to register ok but when i try to launch it in solidworks i get an error message saying that "either the addin or one of its components are missing"
do you have any idea why?
cheers,
--stav.
edit: i have been searching in my registry and i have noticed that under:
hkey_classes_root
there exists a registry entry for each of the classes that are included in the addin e.g:
hkey_classes_root\assemblyname.swaddin
this has a key named clsid with a string named (default) with value the guid of the addin.
do i need to create a key in my setup project for each class included in the addin?
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
edited: 09/09/2008 at 06:29 am by stavros antoniou
the above code will not registry itself correctly or add the registry entries required as the msi installer does not run the .net registry service just the com registry.
this is a problem i encountered when creating my installers and it was a documented bug in vs setup projects that has not been fixed yet that i am aware of. i had to do some trick code to get my programs to register on install.
if you get it working it would be interesting to see the solution. good luck.
hi i am a new developer and i have the problem as you describe here. have you found any solution ?
i just saw this reply and it works !!!
so whoever is still interested in creating an installer class followthe steps described below by tom and you will be able to create an installer for your addins.
if you have any issues reply here and i'll try to help where i can.
once again thanks tom!!!
cheers,
--stav.
originally posted by: thomas mulder
there is a nice easy way to get your plugins to register and unregister themselves using the visual studio install project using an installer class.
i had a lot of problems getting installers to work when i first tried. you can add an install project to your solution and set it to register your addin with com and it does - except it does not excecute the custom register and unregister methods of your addin.
i didn't like the idea of having to manually create registry entries to be excecuted during install so a lot of searching on the web produced the following (assuming you started from the swaddin wizard) :
this works for 32bit windows xp, i haven't tried any other systems so maybe someone can try and let me know. also you may not be able to do this with visual studio express (i'm pretty sure you can't so don't spend too mucjh effort trying!), you might need to get standard or professional.
(1)
add an installer class to your addin project and paste in the following code:
imports system.componentmodel
imports system.configuration.install
imports system.runtime.interopservices
public class installer1
public sub new()
mybase.new()
'this call is required by the component designer.
initializecomponent()
'add initialization code after the call to initializecomponent
end sub
public overrides sub install(byval statesaver as system.collections.idictionary)
mybase.install(statesaver)
dim regsrv as new registrationservices
regsrv.registerassembly(mybase.gettype().assembly, assemblyregistrationflags.setcodebase)
end sub
public overrides sub uninstall(byval savedstate as system.collections.idictionary)
mybase.uninstall(savedstate)
dim regsrv as new registrationservices
regsrv.unregisterassembly(mybase.gettype().assembly)
end sub
end class
(2)
add an installer project to your solution:
file->add-> new project
poject type: setup and deployment
template: setup project
add your addins primary output as the source for the installer project:
right click your setup project and add project output
choose your addins primary output and confirm
select your addins primary output as the install and uninstall custom action:
right click your setup project
choose add->custom action
the custom actions tab will appear
right click the install folder and add you projects primary output
do the same for the uninstall folder
(3)
look for the primay output of your setup project in the solution explorer
click on it and look in the properties change its register flag to vspdadonotregister
the installer class will do this for us.
build your installer class and voila all done for you much easier and will call the following code of your addin:
public shared sub registerfunction(byval t as type)
and
public shared sub unregisterfunction(byval t as type)
hope this is helpful.
cheers
tom mulder
in this world i am nobody...
and nobody is perfect !!!
---------
solidworks office 2008 sp4.0
dell precision pws390
nvidia quadro fx 3450/4000 sdi
quick
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭

相似的主题
主题 主题发起者 论坛 回复 最后发表
【转帖】api to create partdoc objec yang686526 SolidWorks二次开发 0 2009-04-13 08:59 AM
【转帖】api hooks for new bom reorganization functionality yang686526 SolidWorks二次开发 0 2009-04-12 11:04 PM
【转帖】api create dimensioned drawing from par yang686526 SolidWorks二次开发 0 2009-04-12 11:04 PM
【转帖】外挂开发中的封包技术 huangyhg vc编程 0 2007-12-03 04:41 PM
【转帖】对于hook函数的一点认识 huangyhg vc编程 0 2007-03-27 11:53 AM


所有的时间均为北京时间。 现在的时间是 03:35 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多