Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Monday, June 23, 2008

Quick start Visual Studio 2008 on Vista without UAC warning

Do you use Visual Studio 2008 on Windows Vista and still want to keep UAC on but avoid having the time consuming User Account Control warning each time you start VS 2008?

This can be solved by creating a scheduled task that runs with the highest privileges.

This hack can be used to start other programs like the registry editor (regedit.exe) that usually requires a permission to start.

Open Task Scheduler by entering Task Scheduler in the start menu search box.

Click on Create Task...

image

Give the task a name and check "Run with highest privileges".

On the Actions tab click on New.

Enter the path to Visual Studio 2008:
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
and for Start in:
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\

Create a new shortcut.

Enter schtasks /run /tn "VS2008" and change VS2008 so it matches the name of the scheduled task.

Set the  Run option to Minimized and if you want change the icon. Location for the icon:
%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe

Monday, June 02, 2008

ed.SetImpliedSelection(Nothing) doesn't work in AutoCAD 2009

"I upgraded a project to VS 2008 (VB.NET) and AutoCAD 2009 and got this error on the following row:
ed.SetImpliedSelection(Nothing)

Error 1 Overload resolution failed because no accessible 'SetImpliedSelection' is most specific for these arguments:
'Public Sub SetImpliedSelection(selectedObjects() As Autodesk.AutoCAD.DatabaseServices.ObjectId)': Not most specific.
'Public Sub SetImpliedSelection(selectionSet As Autodesk.AutoCAD.EditorInput.SelectionSet)': Not most specific.

Another thing is that SetImpliedSelection is missing in the AutoCAD 2009 .Net API documentation. Not sure if it is on purpose. It was there and worked in AutoCAD 2008.

The object browser still shows it.
Public Sub SetImpliedSelection(ByVal selectedObjects() As Autodesk.AutoCAD.DatabaseServices.ObjectId)
Member of Autodesk.AutoCAD.EditorInput.Editor

The code to replicate this:

Imports Autodesk.AutoCAD Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput Namespace SelectionTest Public Class PickfirstTestCmds <CommandMethod("PFT", (CommandFlags.UsePickSet Or CommandFlags.Redraw Or CommandFlags.Modal))> Public Shared Sub PickFirstTest() Dim doc As Document = Application.DocumentManager.MdiActiveDocument() Dim ed As Editor = doc.Editor ed.SetImpliedSelection(Nothing) End Sub End Class End Namespace

I also find that this still works

Dim objs(0) As AcObjectId ed.SetImpliedSelection(objs)

I'm wondering if it is so that ed.SetImpliedSelection(Nothing) is no longer or not really needed to clear the pickfirst set.

Friday, February 29, 2008

Autodesk introduces VSTA

No VSTA (Visual Studio Tools for Applications) in AutoCAD 2009. I read in the CAD Application Development blog that Revit 2009 has it. That means probably AutoCAD 2010 will introduce VSTA unless Autodesk put resources on other things. AutoCAD have at least VBA and AutoLISP something Revit does not have.

Friday, February 01, 2008

CAD development blog

If you're into CAD development take a look at Josh Johnson - Random musings of a CAD developer where he starts of with NSIS installer and how to attach a DWF with .NET and VS code snippets.

Friday, January 18, 2008

Automate testing of GUI

I just subscribed to http://acadguitest.blogspot.com/. I'm looking forward to read more about his finds on "how to test your AutoCAD applications (AutoLISP, VBA, .NET or ObjectARX) against AutoCAD interface."

Fernando Malard have started looking at AutoIt that is a great product for automation.

Via CADptbr

Monday, January 14, 2008

Lambda expressions and mapcar with VB.NET in VS 2008

I've started to work with Visual Studio 2008 and it's great to see that lambda expressions are supported, something I'm familiar with using in AutoLISP.

I also made a simple .NET variant of the mapcar function. If you have another way or better way let me know.

Module Module1 Sub Main() Dim f1 = Function(i, j) If(i >= j, i & " is " & j & " or more", i & " is less than " & j) Console.WriteLine(f1(1, 0)) Console.WriteLine(f1(-1, 1)) Dim s1 = Function(x, y) x + " " + y Console.WriteLine(s1("Jimmy", "Bergmark")) Dim res() As Object = mapcar(Function(x) x * 2, New Integer() {35, 55, 21, 30}) For Each r In res Console.WriteLine(r) Next Dim mult As Func(Of Integer, Func(Of Integer, Integer)) = Function(x As Integer) Function(y As Integer) x * y Dim mult_2 = mult(2) Dim r1 = mult_2(4) ' r1 is now 8 Console.ReadLine() End Sub Function mapcar(ByVal f As Func(Of Object, Object), ByVal ParamArray x() As Object) As Array Dim res(UBound(x(0))) As Object For i As Integer = 0 To UBound(x(0)) res(i) = f(x(0)(i)) Next i Return res End Function End Module

Here is the output of the code.

output

Tuesday, January 08, 2008

Visual Studio 2008 Shell

Visual Studio 2008 Shell is a new Microsoft product (to be released) based on Visual Studio 2008. Maybe something for Autodesk to make use of instead of the old VLIDE (that is not improved much) and VBAIDE.

"The Visual Studio Shell accelerates development by providing a base integrated development environment that can host custom tools and programming languages."

This means that AutoLISP could be added to this environment.

"Created in response to requests from our partners" - Maybe Autodesk already is working on this...

Visual Studio Shell (isolated mode)

Thursday, December 20, 2007

Using the registry or an INI file to save and retrieve information

When programming there are often information that you want to save and later read. If you consider to use an INI file I suggest you read this post Why are INI files deprecated in favor of the registry?

Here are some reasons I find useful:

  • INI files don't support Unicode.
  • Multiple writers to an INI file can result in data loss.
  • INI files can suffer a denial of service.
  • Parsing an INI file is comparatively slow.

If you think XML is a better choice there are some arguments there as well.

Thursday, November 29, 2007

Extract ISO for Visual Studio 2008 ISO-13346 "UDF"

I downloaded Visual Studio 2008 professional RTM and tried to extract the file en_visual_studio_2008_professional_x86_x64wow_dvd_X14-26326.iso using 7-zip but the only file I got was README.TXT with the following content:
This disc contains a "UDF" file system and requires an operating system
that supports the ISO-13346 "UDF" file system specification.

What I then did that solved this was to run Microsoft Virtual PC 2007 and dragged the ISO file to the CD/DVD icon and then I could drag and drop all files from the virtual PC to the host computer.

Update. A friend send an email and recommended a couple of alternatives. I only tried the first one below.

Virtual CloneDrive is a freeware that virtually mounts the ISO to a drive and it worked great in Vista with the VS 2008 ISO. No 64-bit version yet though.

DAEMON Tools Lite is a freeware that supports both X86 and X64. Be aware that you might want to don't want to or want to uninstall DAEMON Tools Searchbar and Save Now that is included.

Tuesday, November 13, 2007

Dynamsoft SourceAnywhere Hosted Updated

The hosting plans for Dynamsoft SourceAnywhere has been updated as you can see.

Before it was only the Free Plan and the Standard Hosting Plan (US $28/user/month). Now it might be easier to find a plan that works and make sense for your team. Notice also the "Powered by Dynamsoft SourceAnywhere" Plan that is identical to the Enterprise Plan except that the price is less and you are Required to Display "Powered by Dynamsoft SourceAnywhere" Logo. The downside is that the Free Plan is going down from 3 users to 2.

Monday, November 05, 2007

Enable Target and Change Icon of shortcuts

Have you tried to right click on a shortcut and found that Target text box is locked, disabled and grayed out? You have also seen that Open File Location is disabled.

Have you wanted to change icon of a shortcut just to find that the Change Icon button for the shortcut is disabled?

Have you tired to Run as administrator and you cannot find it on the right click menu and on Advanced Properties the checkbox cannot be checked?

When I drag a file and drop it on the shortcut it does not launch the program, why is that?

Often I have found this is the case and been irritated about. A typical user case is that you have an AutoCAD shortcut or some other shortcut that you want to take a copy of and add some command line arguments or switch like /p for starting with a specific profile. Depending on the installer sometimes the desktop shortcut is editable but not the shortcut on the Start menu>All Programs.

The solution is not so much help if you have the product installed so this tip is more useful for the IT manager or the CAD manager.

If you have the product already installed it's probably easiest to locate the EXE executable and make a shortcut manually.

Not long ago I found that this is called "advertised shortcuts" and for example Visual Studio installers creates that as default. It can also be set in tools like Wix, InstallShield, Tarma, etc.

Solution or workaround.

You can run a msi file disabling this behavior using
msiexec.exe <path to msi-file> DISABLEADVTSHORTCUTS=1
or
setup.exe DISABLEADVTSHORTCUTS=1

Or you can set it permanently in the MSI file using the free Orca.

If you want to do this more automated it's possible to use a post build event in Visual Studio and then update the MSI file. Included with the Windows Installer SDK there is WiRunSql.vbs that can be used for this purpose. The SQL look like this:
INSERT INTO Property(Property, Value) VALUES ('DISABLEADVTSHORTCUTS ', '1')

Open the MSI file with Orca and add a new row to the Property table use the name DISABLEADVTSHORTCUTS and the value 1.

Now when installing the shortcuts will behave like expected.

From the Windows Installer Guide on MSDN: DISABLEADVTSHORTCUTS Property.

How to use post build with MSBuild to create non-advertised shortcuts.

Advertised shortcuts.

But what is "advertised shortcuts" and when can this be useful?

This can be useful when deploying applications via GPO (Group Policy Object).

Advertised shortcuts ensures that the shortcuts always have an icon, even if users move from machine to machine. The advertised shortcuts also trigger the installation of an application missing on the machine where the user is currently active. More about advertisement.

Thursday, November 01, 2007

SourceAnywhere Hosted update

Among the news are "Added IP Filter functionality." and "Database encryption improved".

 

There is also an interesting white paper describing how the security works with this SaaS (Software as a Service) solution.

For all news in SourceAnywhere Hosted see the news section on Dynamsoft's website.

One thing I noticed after upgrading and when starting the application was a Global Message telling about that a new version is available. It would be better if it knew what version I have installed.

Other than that SourceAnywhere Hosted is really useful when you collaborate with an extended development team. I recommend you to give it a try.

Wednesday, October 31, 2007

Software Licensing and Protection Services from Microsoft

You probably know how easy it is to disassemble .NET code and it took quite a while for Microsoft to come with a solution. This has been a reason why some companies have not made their applications using .NET code. Obfuscating the code has not been good enough. Actually it was another company that came with a solution. Back in January 2007 Microsoft acquired Secured Dimensions and now they are starting to introduce it as a Microsoft service. Take a look at the new website www.microsoft.com/SLPS. SLP Services is about IP protection, license handling.

SLP Code Protector-  Microsoft SLP Code Protector helps protect .NET code against disassembling and decompilation. Helps to protect .NET code from being hacked and reverse engineered.

I evaluated Code Protector a few months ago and it was easy and quick to get it working. It just took an hour or two to get familiar with the procedures and to be able to protect the first application. In the version I tried, it was not easy to protect DLL code that for example is to be used in-process like a DLL that needs to be loaded with NETLOAD in AutoCAD. There were workarounds for it I didn't care to try and it might be solved by now.

SLP Server 2008 - SLP Server 2008 enables software vendors and publishers to more flexibly and effectively monetize their software. With a new concept Microsoft call “SKU Agility,” the ISV can create multiple offers based on a single image of the software simply by creating digital licenses that map to pre-defined features. Features can be sold individually or accumulated into a set to create SKUs.

Licensing and Activation - are tools to help prevent piracy and serves multiple purposes – protection, license delivery, upselling, and customer service.

A while ago I got a survey from PreEmptive that got me thinking they would come up with a new solution. I now see that PreEmptive Solutions is one of the resellers for SLPS. Dotfuscator has also been extended to instrument (inject) SLPS software into .NET applications.

For more information: The SLPS blog is here and SLPS on MSDN.

Wednesday, October 03, 2007

Review of Dynamsoft software version control

imageI've started to try Dynamsoft SourceAnywhere Hosted and will post more as I continue using it.

I use it together with Visual Studio 2005 but also with other file formats like AutoLISP (Visual LISP) files. There is no limitation on what type of files that can be hosted.

It was very straight forward and intuitive to start using SourceAnywhere Hosted. So far so good.

dynamsoft

If you too want to try it they have a Free Hosting Plan for up to to 3 users and 15M storage space.

image

Disclaimer. I was offered for free a plan of Dynamsoft SourceAnywhere Hosted that receives the same service as the paid account.

Thursday, September 27, 2007

ObjectDBX/RealDWG using VB.NET

acdbmgd.dll contains ObjectDBX/RealDWG managed types (everything to do with manipulating drawing files).

ObjectDBX is useful because you directly access the DWG file without adding the extra resources needed to actually show the drawing. This means that the performance is really good. All entities, objects based on AcadObject and dictionaries can be accessed.

You cannot have a freestanding application that uses ObjectDBX unless you have AutoCAD running. Either a DLL must be created that is loaded from within AutoCAD with the NETLOAD command or you need to use ActiveX to access or connect to ObjectDBX using the AcadApplication object and the GetInterfaceObject method.

ObjectDBX is actually renamed to RealDWG and if you need to use it without having AutoCAD you need to purchase and license it. RealDWG does not require the presence of AutoCAD software. RealDWG 2008 is the latest version available now.

Below is a sample that starts AutoCAD 2008 and opens a drawing with ObjectDBX.

Private Function StartAutoCAD() As Object On Error Resume Next Dim AcadApp As Object ' Get the active session of AutoCAD using late binding AcadApp = GetObject(, "AutoCAD.Application.17.1") If Err.Number <> 0 Then Err.Clear() Shell("c:\Program Files\Common Files\Autodesk Shared\WSCommCntr1.exe", AppWinStyle.NormalFocus) ' Create a new session of AutoCAD using late binding AcadApp = CreateObject("AutoCAD.Application.17.1") End If Return AcadApp End Function Private Sub Test() Dim AcadApp As Object Dim dbxDoc As Object AcadApp = StartAutoCAD() If AcadApp Then AcadApp.Visible = True objDbx = AcadApp.GetInterfaceObject("ObjectDBX.AxDbDocument.17") objDbx.Open("D:\test\block1.dwg") Dim ms As Object ms = objDbx.ModelSpace MsgBox(ms.Count.ToString + " objects in in model space") objDbx = Nothing AcadApp.Application.Quit() AcadApp = Nothing End If End Sub

See also ObjectDBX sample using VBA and AutoCAD 2008 and Copy dimstyles between drawings using VBA for other posts how to use ObjectDBX.

Monday, September 03, 2007

Saving passwords in a database? No!

So how can it be handled in a better way technically speaking? Referencing to the previous post.

Saving passwords in a database as plain text is really a bad idea. Should the passwords be stored in the database encrypted? No, that is not safe either.

Hashing is the way to go. In .NET System.Security.Cryptography you can convert the password into hashes using SHA1 or MD5. Hashing algorithms are one-way, so there is no
way to "unhash" something into a password again if you need to retrieve it. The only thing that can be done is to validate that the password is correct by hashing it and comparing it to the saved hash value. That is why some sites offer you to reset the password but they cannot show you your password.

System.Web.Security namespace has the FormsAuthentication.HashPasswordForStoringInConfigFile Method.

Dim hashedPassword As String
hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(password.Text, hashMethod)

hashMethod can be either "MD5" or "SHA1"

Example: hashing the password 'test' gives the hash: 'ogF4I9nCJZCyYFP0azRLIS5wbvFdmlaHt5krTFW9RirYCdC3SgLbhngWGxYHOKXQ'

But this is still not enough. What if two or more users has the same password. That means that if you manage to get the password from one user you automatically have the password for other users with the same password. This can be exploited in a so called dictionary attack. Why is that? Most users actually uses simple passwords that exists in a dictionary. What the hacker does is to create hashes of a lot of words or passwords and can then compare these hashes to the hashes saved in the database.

Salting hashes is the next step to take. That means that a random string is generated and combined with the password and then hashed. So each user credential row has both a hash as well as a random salt string saved in the database. This will make all hashes unique.

Example: hashing the password 'test' combined with the salt 'Djf983jDJ#64)-d2' gives the hash: '57cjEal0b2+hNRT4sLc2eHL6m/0omTpKk8bkSF8osu9mNF0HG+H6HMFHYzzcR6RR'

This makes it a lot harder for the hacker since he would have to hash all his maybe 1,000,000 dictionary entries with the salt of every user row. That will take so much more time.

So the tip for those that want makes websites that needs to register users or needs to validate passwords one way or the other, do not ever save a clear text password in your database, hash it and use a bit of salt.

There are also other ways to handle web authentication. Take a look at Windows CardSpace and OpenID. OpenID is something you will see more of on Internet, that is for sure.

Update. You can read these posts including comments for more detailed information. Enough With The Rainbow Tables: What You Need To Know About Secure Password Schemes and 2 posts by Coding Horror, Rainbow Hash Cracking and You're Probably Storing Passwords Incorrectly

Tuesday, August 28, 2007

Lines, ovals, and rectangles on forms in Visual Basic 2005

Some basic controls where missing in Visual Studio for a while but now they are included in the released Microsoft Visual Basic 2005 Power Packs 2.0.

image

The workaround to draw a line before was to use this tip in the post "Draw a line at design time in Visual Studio".