乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 81|回复: 1

[编程交流] .Net problem - totally stuck

[复制链接]

10

主题

29

帖子

21

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
68
发表于 2022-7-6 17:19:41 | 显示全部楼层 |阅读模式
I am just starting to play around with using vb.net with AutoCAD 2009. I have experience using VBA and Lisp so I'm not a total noob, but i'm totally stuck nonetheless.
 
I'm running AutoCAD 2009 on 32bit Vista and am programming using vb.Net express 2008.
 
I downloaded the code for "introduction to .net programming" and am trying to get one of the sample commands to work as I go through the tutorial. http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=1911627
 
Here's the code I have: (copied straight from the sample code)
 
  1. [size=2][color=#008000][size=2][color=#008000]' declare a paletteset object, this will only be created once[/color][/size][/color][/size][size=2][color=#0000ff][size=2][color=#0000ff]Public[/color][/size][/color][/size][size=2] myPaletteSet [/size][size=2][color=#0000ff][size=2][color=#0000ff]As[/color][/size][/color][/size][size=2] Autodesk.AutoCAD.Windows.PaletteSet[/size][size=2][color=#008000][size=2][color=#008000]' we need a palette which will be housed by the paletteSet[/color][/size][/color][/size][size=2][color=#0000ff][size=2][color=#0000ff]Public[/color][/size][/color][/size][size=2] myPalette [/size][size=2][color=#0000ff][size=2][color=#0000ff]As[/color][/size][/color][/size][size=2] UserControl1[/size][size=2][color=#008000][size=2][color=#008000]' palette command[/color][/size][/color][/size][size=2] _[/size][size=2][color=#0000ff][size=2][color=#0000ff]Public[/color][/size][/color][/size][size=2][color=#0000ff][size=2][color=#0000ff]Sub[/color][/size][/color][/size][size=2] palette()[/size][size=2][color=#008000][size=2][color=#008000]' check to see if it is valid[/color][/size][/color][/size][size=2][color=#0000ff][size=2][color=#0000ff]If[/color][/size][/color][/size][size=2] (myPaletteSet = [/size][size=2][color=#0000ff][size=2][color=#0000ff]Nothing[/color][/size][/color][/size][size=2]) [/size][size=2][color=#0000ff][size=2][color=#0000ff]Then[/color][/size][/color][/size][size=2][color=#008000][size=2][color=#008000]' create a new palette set, with a unique guid[/color][/size][/color][/size][size=2]myPaletteSet = [/size][size=2][color=#0000ff][size=2][color=#0000ff]New[/color][/size][/color][/size][size=2] PaletteSet([/size][size=2][color=#a31515][size=2][color=#a31515]"My Palette"[/color][/size][/color][/size][size=2], [/size][size=2][color=#0000ff][size=2][color=#0000ff]New[/color][/size][/color][/size][size=2] Guid([/size][size=2][color=#a31515][size=2][color=#a31515]"D61D0875-A507-4b73-8B5F-9266BEACD596"[/color][/size][/color][/size][size=2]))[/size][size=2][color=#008000][size=2][color=#008000]' now create a palette inside, this has our tree control[/color][/size][/color][/size][size=2]myPalette = [/size][size=2][color=#0000ff][size=2][color=#0000ff]New[/color][/size][/color][/size][size=2] UserControl1[/size][size=2][color=#008000][size=2][color=#008000]' now add the palette to the paletteset[/color][/size][/color][/size][size=2]myPaletteSet.Add([/size][size=2][color=#a31515][size=2][color=#a31515]"Palette1"[/color][/size][/color][/size][size=2], myPalette)[/size][size=2][color=#0000ff][size=2][color=#0000ff]End[/color][/size][/color][/size][size=2][color=#0000ff][size=2][color=#0000ff]If[/color][/size][/color][/size][size=2][color=#008000][size=2][color=#008000]' now display the paletteset[/color][/size][/color][/size][size=2]myPaletteSet.Visible = [/size][size=2][color=#0000ff][size=2][color=#0000ff]True[/color][/size][/color][/size][size=2][color=#0000ff][size=2][color=#0000ff]End[/color][/size][/color][/size][size=2][color=#0000ff][size=2][color=#0000ff]Sub[/color][/size][/color][/size]
 
So the code would work, I created a usercontrol with a treeview on it, and nothing else. It is named usercontrol1.
 
The code is erroring out at the line:
myPaletteSet.Add("Palette1", myPalette)
 
I am getting the following error returned to me:
 
"Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
 
and a snippet from the exception detail:
 
"System.Security.SecurityException was unhandled by user code"
 
Any ideas from the more experienced programmers out there?
回复

使用道具 举报

10

主题

29

帖子

21

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
68
发表于 2022-7-6 19:08:17 | 显示全部楼层
After some digging around I found out that the problem is that the .dll I was loading was on a network drive and this was causing some sort of permission issue with .net when loading a palette.
 
Once I moved the .dll onto my local drive everything seemed to work just fine.
 
If any of you have additional insite on this, let me know.
 
Thanks,
 
Joe
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 15:42 , Processed in 0.348877 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表