infolink

Wednesday, December 29, 2010

LINQ to SQL DataContext is not accessable, does not show even in intellisense

I have been seeing this strange behavior using LINQ to SQL in Visual Studio 2008 in the last two months.

I was working on a project and defined my DataContext using the LINQ designer. I applied the same namespace as my main class, yet in my main class I do not see my data context, and when I try to type it, it states it does not exist. I check the backend code of the LINQ designer and everything looks right, same namespace and the DataContext is named properly.

I played around trying many things to no avail, so as a last ditch effort I reinstalled Visual Studio 2008 SP1.

When I went back into Visual Studio 2008 I tried to type out my DataContext variable and still same issue, it wasn't accessable. So I then deleted my LINQ to SQL class.

I now recreate my LINQ to SQL class. Add my stored procedures, save the DataContext and then back to my class and guess what, it is there.

So, now here I am, different machine, a month later, same exact issue on a ASP.NET Web Application in Visual Studio 2008. It would not see my Data Context. So I repeat the steps that fixed it for me before in the follow order:

#1 Reinstalled Visual Studio 2008 SP1 (Yes, on both machines I had already installed Visual Studio 2008 SP1)

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en

#2 Open project back up and delete the Linq To SQL class

#3 Recreate the LINQ to SQL class in the designer

#4 Save and Recompile

That was it, it is now working as expected on this machine also, very strange, hope this helps someone else. The other project type was a ASP.NET Web Service.

Tuesday, December 28, 2010

How to read Excel file in .Net C# and VB.NET

I have many times int the past been asked to import/export data from an excel spreadsheet. In the past I have used Interop and OLEDB, but I found this to be a simple dll which allowed me to roll this stuff out a bit faster. This a very simple, lightweight DLL which allows you to read from an excel spreadsheet without Interop and installing an obsolete OLEDB dll.

Excel Data Reader - Read Excel files in .NET

Lightweight and fast library written in C# for reading Microsoft Excel files ('97-2007).
Cross-platform:
- Windows with .Net Framework 2
- Windows Mobile with Compact Framework
- Linux, OS X, BSD with Mono 2+

http://exceldatareader.codeplex.com/

Wednesday, November 17, 2010

How to get Fiddler to work with local host in asp.net while debugging in Visual Studio

Well I have been using Fiddler for some time now and it is a great tool when debugging a web application in ASP.NET/

Currently I use Visual Studio 2008 SP1 and there have been many issues with images not loading and request handling that Fiddler has helped me solve. it is by far one of the best web debugging tools out there.

You can grab it at http://www.fiddler2.com/fiddler2/
target="_blank"


For now if you put http://localhost./ (NOTICE THE DOT) it will work with Visual Studio

Timed out waiting for a program to execute. The command being executed was "C:\WINDOWS\Microsoft.NET\Framework\v3.5\vbc.exe"

Well today was boatloads of fun. I make a quick change to an aspx file in a DotNetNuke project and all the sudden the site started to hang. After about 10 minutes or so I got the following error:

Timed out waiting for a program to execute. The command being executed was "C:\WINDOWS\Microsoft.NET\Framework\v3.5\vbc.exe"/noconfig @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\2e8bd0df\9885eac5\lqud30cx.cmdline".

So first thing I thought is since this file was in the skin of my DotNetNuke site that the compiler must have detected a change in the code and tried to recompile. I must have broke soemthing , right?

No, as I restored the site filesystem with a backup and did a restore of the SQL 2008 Database. I still get the same error:

Timed out waiting for a program to execute. The command being executed was "C:\WINDOWS\Microsoft.NET\Framework\v3.5\vbc.exe"/noconfig @"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\2e8bd0df\9885eac5\lqud30cx.cmdline".

So, what gives, I looked around and cannot find an answer to this issue. Microsoft tells me to do this:

• Reinstall the asp.net (aspnet_regiis –u then aspnet_regiis -i)
• Gave required permissions on ASPNET account by running aspnet_regiis -ga ASPNET


For anyone who doesn't know the actual command it is:

This will uninstall ASP.net:

C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/aspnet_regiis -u

This will install ASP.net:

C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/aspnet_regiis -i

When I ran the install I got the following error at the command line:

...............
Finished installing ASP.NET (2.0.50727).
Setup has detected some errors during the operation. For details, please rea
e setup log file C:\DOCUME~1\USERNAME\LOCALS~1\Temp\1\ASPNETSetup_00005.log

Now, when I look at the log, I see this in the log:

Failure Creating directory: E:\MYWEBAPP\aspnet_client: CreateDirectoryInternal failed with HRESULT 80070003: 'The system cannot find the path specified. '

This error only occurs on the .Net application where this error started.

I then deleted the aspnet_client directory and ran aspnet_regiis -u
and then aspnet_regiis -i

My issue still remains. I also made sure the security account permissions were correct.

I also stopped IIS and all related services and deleted the asp.net temp files located in c:\Windows\Microsoft.NET\Framework\v2.0.50727\

This did not help

At this time I have no resolution...

UPDATE:


Try to run the app pool under the identity "LOCAL SYSTEM"

Then run IISREST

load your page.

If this works check the framework folders or what was my major issue is your temp folder, in my case C:\Windows\Temp . Make sure NetworkService has proper permissions. Add full permissions to confirm this isn't the issue.

Now, I know this permission was there so, some how it just dropped off, which is just plain odd. Did take some updates recently and this didn't become an issue until I made a code change which forced IIS to recompile the site.

This server is now back up and running.
Buy Me a Beer

Thursday, October 21, 2010

What would be your desire?

If someone came to you and asked you. I will write a software application for you that will do anything you want, speed up some manual process, check your stocks, reply to your facebook posts, etc.. What would your response be?

Wednesday, October 20, 2010

ISearchable

Well I have decided to use the Isearchable interface available in the DotNetNuke Core. FOund a great article by Micheal Washington who I highly recommend to anyone. He taught me all about Silverlight in DNN and it's communication, anyway here is the article he wrote all about the ISearchable interface in DNN:

http://www.adefwebserver.com/DotNetNukeHELP/ISearchable/

Tuesday, October 19, 2010

DotNetNuke Search Module

Over the last week I had a request to create or extend the dotnetnuke core search module. Well thinking this should be simple, I dove right in.

What a mess, who would have written this, this way, what a pain. Out of the box, searching pages created and edited in dotnetnuke, no problem, works like a charm. Plug in other modules, the option of video, and sorting by category and what we got here is a clusterf*ck.

So, time to write into the core and extend with my lovely thumbnail control. I hate changing the core and will try to use a custom control, but I have a feeling seeing how the ISearchable interface is, I may have to make some changes to the core.

Will post more about this adventure later...

Sunday, October 17, 2010

Visual Studio 2010 crashing for no reason

Having some issues with upgrading older project. They upgrade fine and the report generated says everything went well. I make warning and error changes and recompile and Visual Studio 2010 just hangs while building. I have let it run overnight for the heck of it and still no errors or anything, so for now, back to Visual Studio 2008 for older projects. this project was writtern in .Net 1.1

Wednesday, August 11, 2010

Unable to Start Debugging on the Web Server

Using IIS6 on a Windows 2003 Server. I launch Visual Studio 2008 to debug on a custom webserver and I got the error "Unable to Start Debugging on the Web Server". I screwed around with a bunch of suggestions to no avail. I then tried the follow:

Specify host names (Preferred method if NTLM authentication is desired)
To specify the host names that are mapped to the loopback address and can connect to Web sites on your computer, follow these steps:
Set the DisableStrictNameChecking registry entry to 1.

Click Start, click Run, type regedit, and then click OK.
In Registry Editor, locate and then click the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
Right-click MSV1_0, point to New, and then click Multi-String Value.
Type BackConnectionHostNames, and then press ENTER.
Right-click BackConnectionHostNames, and then click Modify.
In the Value data box, type the host name or the host names for the sites that are on the local computer, and then click OK.
Quit Registry Editor, and then restart the IISAdmin service.


This fixed it, answer found here:
http://support.microsoft.com/?kbid=896861

Tuesday, May 4, 2010

How to: Install and Uninstall Services

installutil /u yourproject.exe

installutil is located in the Windows folder [WINDOWS\Microsoft.NET\Framework\v2.0....]

Wednesday, April 14, 2010

Silverlight Debugging XAML

Well I found it hard the other day to try and debug the XAML Parser. I was having an issue in Silverlight 2 and databinding. I came accross several posts and have heard from Microsoft that we cannot debug the XAML Parser. I needed to see the values of what was rendered XAML.

It almost seemed impossible until I came accross a great tool by First Floor Software called Silverlight Spy.

All I can say is that this tool saved me and is something that will remain in my toolkit forever:

http://firstfloorsoftware.com/silverlightspy/download-silverlight-spy/

Fully functional for thrity days and less than 200$, well worth it.

Getting a child element in Silverlight - Simple solution

I needed to get a child element of my layout root. I knew the index, but most examples out there were so confusing and way too involved for something that seemed so easy. This reminded me of a comment from a developer at Microsoft:

"If it seems too hard or way too much code, you must doing it wrong" - Trevor Fellman

You what, great advice, it turns out I found the following examples:

Get Child, Parent, or Children Objects in Silverlight:

http://www.mostlydevelopers.com/mostlydevelopers/blog/post/2009/06/17/Get-Child-Parent-or-Children-Objects-in-Silverlight.aspx

Great advice, if I didn't know the index of the object, yet I do, (Silverlight Spy is your friend)

Then I came across this:

LINQ to Visual Tree

http://www.codeproject.com/Articles/63157/LINQ-to-Visual-Tree.aspx

very neat stuff and I see myself using this in the future, but too involved for what I needed to do.

I then found this:

VisualTreeHelper Class

http://msdn.microsoft.com/en-us/library/system.windows.media.visualtreehelper(v=VS.95).aspx

Not this had me thinking, how can I simply call this and get my object in c# all in one simple line of code, and here is what I came up with:
ImageScroll myimagescroll;
myimagescroll = (VisualTreeHelper.GetChild(this.LayoutRoot, 7) as ImageScroll);
What this line does is exactly what i was looking for. My object IMAGESCROLL, which is index #7 in the collection(children) of the Layoutroot Grid Object.

Sunday, April 11, 2010

Visual Studio 2010 Launch Tomorrow April 12th

Cannot wait, Loving what I am hearing about the new Silverlight switching. No more batch file yay. If you want to watch the launch you can watch it here:

http://www.devconnections.com/shows/SP2010VS/default.asp?s=144

Notes from page:

The topics will range from all the new, great features in Visual Studio 2010 to Silverlight, WPF, WF, WCF, Application Lifecycle Management, .NET 4.0, ASP.NET 4.0 AJAX, ASP.NET MVC and much more!




And remember: If you sign up for Microsoft Visual Studio Conference & Expo, you'll automatically get access to both the ASP.NET and Silverlight and the SQL Conference and Expo! That's a Visual Studio launch and three conferences for the price of one!



In addition to insightful keynotes by Bob Muglia, President, Server and Tools Business and Scott Guthrie, Corporate Vice President, .NET Developer Platform, see key members of the Visual Studio team including Doug Seven, Sean McBreen, Chris Sells and Andy Conrad. Also see favorites from the third-party community including Juval Lowy, Michele Leroux Bustamante, Billy Hollis, Tim Huckaby, Rocky Lhotka, Dan Wahlin, Steven Smith, and Rick Strahl. Listen to a live recording of .NET Rocks! with Carl Franklin and Richard Campbell.



If you compare the number of expert speakers and in-depth sessions we offer to other conference events, you'll realize that this is the best value out there! And the Bellagio Resort is the perfect set of surroundings for our event.

Here is the launch Schedule:
 
http://www.devconnections.com/shows/images/schedulepdfs/S10_VS_Sched_v14.pdf

Wednesday, March 31, 2010

Windows Update KB980182 in Windows 7 X64 Video stops playing

Well it looks like microsoft screwed this update up, least on my machine.

Last night I was informed that a security update had been applied. I rebooted and went to sleep. Windows 7
 Cumulative Security Update for Internet Explorer (980182) had been applied and caused my machine to no longer play any video.
This includes Flash,Silverlight, AVI, WMV, and any other video format to load, show first frame and then lock up.

The only way I fixed this and figured out it was the update was to do a system restore to last nights state.

I hope microsoft fixes this issue, as of now, I have to ignore this security update.

http://www.microsoft.com/technet/security/bulletin/MS10-018.mspx

Saturday, March 27, 2010

WPF and Silverlight Programming

I have been programming Silverlight for some time now. I have had some hard times trying to grasp the design end and have found some great resources that I would love to share. Hopefully it helps you like it has helped me with Silverlight and WPF:

Windows Presentation Foundation
WPF Architecture

http://msdn.microsoft.com/en-us/library/ms750441.aspx#

XAML
http://msdn.microsoft.com/en-us/library/ms747122.aspx

Base Elements
http://msdn.microsoft.com/en-us/library/ms746683.aspx

Element Tree and Serialization
http://msdn.microsoft.com/en-us/library/ms750605.aspx

Properties
http://msdn.microsoft.com/en-us/library/ms753192.aspx

Guidance on Differences Between WPF and Silverlight
http://wpfslguidance.codeplex.com/

Friday, March 26, 2010

SQL Server - Get Row Count in Table TSQL

I was working on a shared site machine over at Ektron Hosting and hating this MyLittleSQLAdmin utility they have, doesn't even give row counts like SQL management studio.

So I needed a quick way to get total row counts on my table, this worked just fine:

USE [OURTABLEHERE]
GO
SELECT OBJECT_NAME(OBJECT_ID) TableName, st.row_count
FROM sys.dm_db_partition_stats st
WHERE index_id < 2
ORDER BY st.row_count DESC
GO

Monday, March 22, 2010

How to clear Visual Studio 2008 Recent Project List

Well I was getting so frustrated at my Visual studio List being full of old unused projects when I opened it up, that I needed a way to clear the Visual Studio 2008 Recent Project List. All you need to do is create a reg file with the following code:


Windows Registry Editor Version 5.00

[-HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\ProjectMRUList]
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\ProjectMRUList]


Save it as a .reg file and run it, restart Visual Studio 2008.

Tuesday, March 9, 2010

How to parse Meta Tags

The other day I needed to parse a custom ASP.NET meta tag. Here is what I came up with:

List metas = new List();
foreach (Control c in this.Page.Header.Controls)
if (c.GetType() == typeof(HtmlMeta))
{
HtmlMeta meta = (HtmlMeta)c;
if (meta.Name == "CategoryID")
strMeta = meta.Content;
}

Saturday, February 27, 2010

How to create your own DotNetNuke Registration page

About a week ago I was working on a project that required user registration. The out of the box registration form included in the core framework of DNN was just not what I wanted. I spent quite a few hours trying to figure out how to create my own. All I could find were modules to purchase or create my own membershipo provider.

Well purchasing a module was not in my scope as I wanted to figure out how. Creating my own provider was just too much work. So I decided to dive into the core code and here is what I came up with:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Web.UI;
using System.Web.UI.WebControls;

using DotNetNuke;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;
using DotNetNuke.Security.Membership;
using System.Web.Security;
using System.Threading;
using DotNetNuke.Common;
using DotNetNuke.Entities.Users;


namespace DotNetNuke.mymods.Modules.Membership
{
/// -----------------------------------------------------------------------------
///
/// The ViewMembership class displays the content
///

///
///

///
///

/// -----------------------------------------------------------------------------
partial class ViewMembership : PortalModuleBase, IActionable
{

#region Private Members

private string strTemplate;

#endregion

#region Public Methods

public bool DisplayAudit()
{
bool retValue = false;

if ((string)Settings["auditinfo"] == "Y")
{
retValue = true;
}

return retValue;
}

#endregion

#region Event Handlers

/// -----------------------------------------------------------------------------
///
/// Page_Load runs when the control is loaded
///

///
///

///
///

/// -----------------------------------------------------------------------------
protected void Page_Load(System.Object sender, System.EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}

}
public void btnRegister_Click(object sender, EventArgs e)
{
try
{

UserCreateStatus userstatus = UserCreateStatus.AddUser;
UserInfo NewUser = new UserInfo();
NewUser.PortalID = 0;
NewUser.FirstName = txtFirstName.Text;
NewUser.LastName = txtLastName.Text;
NewUser.Username = txtEmail.Text;
NewUser.DisplayName = txtFirstName.Text + " " + txtLastName.Text;
NewUser.Profile.City = txtCity.Text;
NewUser.Profile.Country = "United States";
NewUser.Email = txtEmail.Text;
NewUser.Username = txtEmail.Text;
NewUser.Membership.Password = txtNewPassword.Text;
NewUser.Profile.SetProfileProperty("State", ddlState.SelectedValue);

if (PortalSettings.UserRegistration == Convert.ToInt32(DotNetNuke.Common.Globals.PortalRegistrationType.PublicRegistration))
{
NewUser.Membership.Approved = true;
}
else
{
NewUser.Membership.Approved = false;
}

UserCreateStatus userstatsus = UserController.CreateUser(ref NewUser);
switch (userstatsus.ToString())
{
case "Success":
{
MessageCell.InnerHtml = "you have successfully registered";

break;
}
case "InvalidPassword":
{
MessageCell.InnerHtml = "Your password is too short";
break;
}

default:
MessageCell.InnerText = "" + userstatus.ToString() + "";
break;
}
}


//MessageCell.InnerText = userstatsus.ToString();

catch (Exception ex)
{
Console.Write(ex);
}

}

protected void lstContent_ItemDataBound(System.Object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
{
string strContent = strTemplate;
string strValue = Null.NullString;

//add content to template
ArrayList objProperties = CBO.GetPropertyInfo(typeof(MembershipInfo));
int intProperty;
foreach (PropertyInfo objPropertyInfo in objProperties)
{
if (strContent.IndexOf("[" + objPropertyInfo.Name.ToUpper() + "]") != -1)
{
strValue = Server.HtmlDecode(DataBinder.Eval(e.Item.DataItem, objPropertyInfo.Name).ToString());
strContent = strContent.Replace("[" + objPropertyInfo.Name.ToUpper() + "]", strValue);
}
}

//assign the content
Label lblContent = (Label)e.Item.FindControl("lblContent");
lblContent.Text = strContent;
}

#endregion

#region Optional Interfaces

/// -----------------------------------------------------------------------------
///
/// Registers the module actions required for interfacing with the portal framework
///

///
///
///
///
///

/// -----------------------------------------------------------------------------
public ModuleActionCollection ModuleActions
{
get
{
ModuleActionCollection Actions = new ModuleActionCollection();
Actions.Add(this.GetNextActionID(), Localization.GetString(ModuleActionType.AddContent, this.LocalResourceFile), ModuleActionType.AddContent, "", "", this.EditUrl(), false, SecurityAccessLevel.Edit, true, false);
return Actions;
}
}

#endregion

}
}

Thursday, February 25, 2010

Best 404 Errors Ever

Great article over at the huffintonpost, vote for your favorite 404 page:

http://www.huffingtonpost.com/2010/02/11/best-404-error-pages-ever_n_456767.html

Agent Ransack an Awesome free tool!

Figure I should pass this on, especially to those that have found google desktop to be a hog and windows search not working as expected.

Many times I have found myself looking for that file, the text in the file, or occurrences of a term in multiple files.

For so long I delt with what I knew of, which wasn't much then stated above. Well, one day someone suggested this program to me called Agent Ransack.

The minute I installed it, I fell in love. It works so well and has helped me immensely, especially when it comes to diving into someone else's code. It not only tells you the files the term occurs in, it tells you the line numbers in the file (yuuuuuuuummmmm).

Anyway, I do not work for them, was never asked to review this, I just want to pass this on. You can download it for free here:

http://www.mythicsoft.com/agentransack/Page.aspx?page=download

ASP.NET FileUpload Web Control Issue in DotNetNuke

Today I uploaded a form which included an ASP.NET File Upload Control. At first glance it looked like everything was fine. It turns out, no matter what I did the controls hasfile property was false.

After some searching I came accross this on MSDN:

Note:
The FileUpload control is designed to be used only in postback scenarios and not in asynchronous postback scenarios during partial-page rendering. When you use a FileUpload control inside an UpdatePanel control, the file must be uploaded by using a control that is a PostBackTrigger object for the panel. UpdatePanel controls are used to update selected regions of a page instead of updating the whole page with a postback. For more information, see UpdatePanel Control Overview and Partial-Page Rendering Overview.


Well hmm, this is in dotnetnuke and in it's settings page which I know is an update panel this has to be my issue. So as a workaround and instead of using a PostBackTrigger, I decided to use the build in dnn upload control located in root/admin/files/webupload.asx.

Wednesday, February 24, 2010

Do you travel with your pet?

If so check out this site, great people and good application. They are a community for pet lovers alike. Hotel pet policies and booking all online. Great destination travel guide and an interesting road trip planner. Check them out and go pet friendly.

Plus, I personally did a bunch of work on this site and Amy and Rod are the best!

http://www.gopetfriendly.com

DotNetNuke Module Deployment

Yesterday I posted a DotNetNuke Module in DotNetNuke version 4.9.2. At that time, when I would bring up the page I put the module on, nothing but the skin would appear. I did the following to troubleshoot it:

  • Check code - exact match
  • Check DNN Event Log - clean
  • Look for errors - none
  • Restart Site - same issue
  • Check Windows Logs - clean
  • Bang Head against desk - same issue, although now I have a headache
Lastly, I decided to go line by line in the code to figure out where my module was failing and not causing any errors.

I am currently using an ASP.NET MultiView, which I populate using XSLT. The XSLT file I call when doing the transform had a local path, since the file was not found, the control don't load. Funny my try catch didn't work, but as soon as I changed the path to the XSLT file everything worked out fine.

Amazon1