Cross Language

by Lord Cod3n 27. August 2008 07:06

Today is a busy day for posting.  I have found that it helps get my thoughts in order. It also allows me to work on my communication skills.  I am a very verbal person and putting things on paper is sometimes difficult.  I have found in Visual Studio 2005 that you cannot go to definition to another language.  I am unable to go to definition from a c# project to vb.  I don't think this a problem that will hit a lot of people.  I am developing my current project in vb by request, and the testing framework is in c#.  I have found another oddity.  It seems that when you make changes in the vb code you have to remove and re add the reference even though i have a project reference.  It is very interesting.  

****EDIT******

So I have not found much evidence to support what I experienced.  My understanding is this should work with no issues.  I will keep digging and see if I find anything.

Remember to Code Happy,

bill

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Generics

by Lord Cod3n 27. August 2008 05:14

I switched tasks again.  I love adhd and I am trying to do some work for one of my clients.  I am writing a piece of code that pulls and validates information from an excel file.  I am given a lot of freedom in the implementation.  The only constraint is I have to use visual studio 2005.  I wrote a function to convert integers.  I wrote a function to covert Doubles.  I wrote a function to convert Strings.  So on and so forth.  I have been working with generics a bit.  All my previous jobs did not present me with the opportunity to dig deep.  What I am trying to accomplish is below: 

If you know of a solution let me know.  I will post up if I find anything. 

Private Sub ConvertFromString(Of T)(ByRef conversion As T, ByRef cell As String)

T.TryParse(getItem(cell), conversion)

End Sub

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Linq To CSV Project

by Lord Cod3n 27. August 2008 02:59

I am writing a Linq to CSV provider.  I may publish the source code, and if not the source then the dll.  Send me a note.  The first Task I am doing is learning about the following interfaces

1.  IQueryable

2.  IQueryProvider

I will post details as I implement them.

 

***Update*****

As it turns out alot of other people already implemeted this idea.  Instead of re-inventing the wheel I will point you to one of the ones I found.

 

http://www.codeproject.com/KB/linq/LINQtoCSV.aspx

 

I am instead focusing my time on silverlight , WPF, Dynamic Data, Asp.net MVC, and other technologies that cross my path.  Let me know if you want anything specific.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Linq to Sql Performance Improvements

by Lord Cod3n 26. August 2008 04:53

The originally article can be found here:

http://blogs.msdn.com/dinesh.kulkarni/archive/2008/08/10/net-fx-3-5-sp1-two-perf-improvements-linq-to-objects-and-linq-to-sql.aspx

Cast<T> break change.  The RTM version allowed for you to cast object that should have been invalid.  You could query and cast a float to an integer.   This is not allowed because of the possibility of data loss.

Standard execution time for querying a collection has been improved.  I understand the performance increase to apply to using Where and Sort.  However the way the article reads there seem to be improvements to queries not using Where or Sort as well.

Linq to Sql has fixed an error when caching identity based data.  Previously the query would be executed again even if the identity row was already in the cache.

A lot of my development at this time is leveraging LINQ to SQL, and LINQ.  These are both huge time savers and remove the tedium of writing that same old data access layer.  It allows you to spend some time learning some new patterns and working on writing solid code.  I think with these tools in our toolbox part of the data access layer problem has been solved.  They allow you to focus more on the application than the data. 

There are other features introduced into this problem space.  They target this problem as well and include the entity framework, and by extension the LINQ to Entities.  This gets the middle and front end developers more into domain based programming instead of a one to one class mapping of objects from the database.  Go forth and abstract.

As always Code Happy,

Lord Coden

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Dynamic Data

by Lord Cod3n 25. August 2008 05:16

I am going blog further on this.  I wanted to get the word out Dynamic Data seems to very useful.  You can bind to collections, linq to sql, and objects.  The Dynamic Data framework automatically generates a standard CRUD and UI.  Everything works really well, and it is very customizable.  I will upload a video showing the creation of a Dynamic Data website.  You can get some more information from here:

http://weblogs.asp.net/scottgu/archive/2007/12/14/new-asp-net-dynamic-data-support.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Lovely Part Deux

by Lord Cod3n 18. August 2008 07:55

Here is my second post on a multi-part test.  OK so to give you something useful.  Have you checked out windows powershell? 

http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx

I think using get-childitem to search your folders is pretty cool.  You can even format the results.  Here is a sample to query your c drive for any mp3's.

get-childitem -r c:\ -filter *.mp3 | format-list 

You can substitute any path for the c:\.  You can also use \\mypc\share  or a mapped drive.  You can also search your environment variables and the registry using this method.  I used a similar query to look for duplicated movie files on my media drive.  I am itunes paranoid because you cannot re-download them.  The command line is a little bit more complex, but it will demostrate the use of select and where commandlets. I will post that command line as soon as I find my notes.

Code Happy,

Bill

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Creating a Service with Visual Studio 2005

by Lord Cod3n 12. August 2008 03:20

Here is where I got the knowledge I need

http://aspalliance.com/1316_Working_with_Windows_Service_Using_Visual_Studio_2005

Safari OReilly ... I love this site, it saves me 100's of dollars a year by not having to purchase books.

http://safari.oreilly.com/

As promised in my previous post, here is some code you can use to impersonate in your application/service. 

I tested this in a service wrapper that was just garbage code, so I am only posting the impersonation class I converted.   One aside I would like to point out that I think is interesting is in a web.config, you can use an impersonate node to handle your permission issues with a different login.  With a windows application you have to explicitly call the win32 api’s.  I converted this from a c# example  found here . 

http://forums.asp.net/t/203769.aspx

 

Method Generation provided by  Really cool tool just found out about it

 http://www.codeplex.com/clrinterop/Release/ProjectReleases.aspx?ReleaseId=14120

 

Notice Default in the LoginProvider is called myDefault.  This is because Default is a reserved word in VB.  Since Enum are just number I felt safe making this change. 

'<summary>

'Provides methods for Identity impersonation.

' </summary>

Public Class Impersonation

'<summary>Used for the impersonation API calls.</summary>

Public Enum LogonType

Interactive = 2

Network

Batch

Service

End Enum

'<summary>Used for the impersonation API calls.</summary>

Public Enum LoginProvider

myDefault

WinNT35

End Enum

'<summary>Internal windows function used for loging in as a user</summary>

'<seealso cref="VerifyDomainPassword"/><seealso cref="BeginImpersonation"/><seealso cref="EndImpersonation"/>

'<param name="lpszUsername">The user name of the user to log in as</param>

'<param name="lpszDomain">The domain the user is in</param>

'<param name="lpszPassword">The users password</param>

'<param name="dwLogonType">Method of logging in. <see cref="LogonType"/></param>

' <param name="dwLogonProvider">Which provider to log in with. <see cref="LogonProvider"/></param>

'<param name="phToken">Token returned that points to the user. Needed for impersonation</param>

'<returns>False for success True for error</returns>

<System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint:="LogonUserA")> _

Public Shared Function LogonUser(<System.Runtime.InteropServices.InAttribute(), System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)> ByVal lpszUsername As String, <System.Runtime.InteropServices.InAttribute(), System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)> ByVal lpszDomain As String, <System.Runtime.InteropServices.InAttribute(), System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)> ByVal lpszPassword As String, ByVal dwLogonType As UInteger, ByVal dwLogonProvider As UInteger, ByRef phToken As System.IntPtr) As <System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)> Boolean

End Function

<System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint:="ImpersonateLoggedOnUser")> _

Public Shared Function ImpersonateLoggedOnUser(<System.Runtime.InteropServices.InAttribute()> ByVal hToken As System.IntPtr) As <System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)> Boolean

End Function

<System.Runtime.InteropServices.DllImportAttribute("advapi32.dll", EntryPoint:="RevertToSelf")> _

Public Shared Function RevertToSelf() As <System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)> Boolean

End Function

Public Shared Sub BeginImpersonation(ByVal UserId As String, ByVal Password As String, ByVal Domain As String)

Dim tokenHandle As IntPtr = IntPtr.Zero

Dim ret As Int32

Try

If Not (LogonUser(UserId, Domain, Password, LogonType.Interactive, LoginProvider.myDefault, tokenHandle)) Then

If Not (ImpersonateLoggedOnUser(tokenHandle)) Then

Throw New Exception("Could not impersonate")

End If

End If

Catch ex As Exception Throw New System.Exception("Problem Beginning Impersonation", ex)

End Try

End Sub

Public Shared Sub EndImpersonation()

Try

If Not (RevertToSelf()) Then

Throw New Exception("RevertToSelf;Failed")

End If

Catch ex As Exception Throw New Exception("Problem Ending Impersonation", ex)

End Try

End Sub

End Class

 

 

More to come in a bit , Code Happy

01100010011010010110110001101100

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

I Love new features

by Lord Cod3n 11. August 2008 15:02

From my local .net users group

 

Visual Studio 2008 SP1 has been released. 


Thanks NetDug Support Team.
support@netdug.com

 

Here is a list of new features I am really excited about.

1.  Full Support for legacy asp.  This includes debugging.

2.  Auto formatting for javascript.

3.  Entity Data Model Designer- this allows to you create edm (entity maps from your database or other data source).

Code Happy 

01100010011010010110110001101100

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Permissions

by Lord Cod3n 11. August 2008 08:54

I ran into an issue where a client was having a permissions issue.  I would like to note that you should keep in mind when you spawn a process, either from your own process or a service or from the command line, that process inherits the running process permission level.  If a service has local system privileges, then any process created by that service will have Local System Privileges.  This means that a spawned process from a service with Local System rights cannot access another computer on the domain.  You should create a domain account for your service. 

I am creating a sample class and will post it shortly.

 Thanks and as always  Code Happy.

01100010011010010110110001101100

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Intro

by Lord Cod3n 11. August 2008 07:29
 

So here is our first ever post.  WOW! So far getting laid off was one of the best things to ever happen to me.  I am/was a software architect.  I live in Boise and due to a recent turn of events from my former employer, I am now the proud contributor to Coden Enterprises.  I love it! Life is a lot more stressful when you take a 75,000 dollar pay cut.  I don't mind, I am getting to see my daughter grow up (She is three months old). 

 

I am going to try to offer some good programming tips and discussion points.  We will see how it goes.  Some posts will be technical, some will be family related, and others will be business related.  Getting a feel for the whole process will make you and I better developers.  I am strongly into middle-tier/database development.  I can work effectively as a developer and a DBA.   I think SQL and databases are underutilized in our community.  Most developers I have worked with only had a real basic understanding of SQL Server. If you want to be more marketable, dust of those database theory books from college and dig in! 

 

We are about to start our kids and a couple of neighbors on this program:

 

http://msdn.microsoft.com/en-us/beginner/bb308754.aspx

 

This seems pretty neat

 

 

I will be back soon and as always Code Happy

 

01100010011010010110110001101100

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

William Moore is the lead Software Architect and Technologist for Coden Enterprises. He has more than a decade of software development experience primarily Microsoft Platforms.  William enjoys the full gamit of coding everything from the UI down to the database.

Most comments

Page List