Here is a link to a great post on configuration recommendations for development environments.
http://blogs.msdn.com/bharry/archive/2010/04/29/your-visual-studio-2010-dream-machine.aspx
.Net Developer, Blogger, VP Development EIS, Public Safety Software (Police, Fire, EMS, Jail)
Here is a link to a great post on configuration recommendations for development environments.
http://blogs.msdn.com/bharry/archive/2010/04/29/your-visual-studio-2010-dream-machine.aspx
Ever need to get all the triggers in a SQL database. This script will return them;
SELECT S2.[name] TableName, S1.[name] TriggerName,
CASE
WHEN S2.deltrig = s1.id THEN 'Delete'
WHEN S2.instrig = s1.id THEN 'Insert'
WHEN S2.updtrig = s1.id THEN 'Update'
END 'TriggerType' , 'S1',s1.*,'S2',s2.*
FROM sysobjects S1 JOIN sysobjects S2 ON S1.parent_obj = S2.[id] WHERE S1.xtype='TR' order by TableName
Silverlight Spy provides detailed runtime inspection of any Silverlight application. Use the built-in browser to navigate to a web page.
Silverlight Spy automatically detects the applications embedded in the page and provides various inspection view panes. Explore the XAP package, Isolated Storage, monitor performance, browse the UI visual and logical tree, examine objects, execute code in the DLR shell and more.
The Generate From Usage feature enables you to use classes and members before you define them. You can generate a stub for any class, constructor, method, property, field, or enum that you want to use but have not yet defined. You can generate new types and members without leaving your current location in code. This minimizes interruption to your workflow.
Generate From Usage supports programming styles such as test-first development.
Using Generate From Usage in Visual Basic
A wavy underline appears under each undefined identifier, and a short underline appears under the rightmost character. When you rest the mouse pointer on the identifier, an error message appears in a tooltip.
To display the appropriate options, you can use one of the following procedures:
Rest the mouse pointer on the undefined identifier. A smart tag (an icon) appears. Click the smart tag.
Click the undefined identifier, and then press CTRL+. (period).
In the Error List window, double-click the corresponding error row.
The options that appear can include the following:
Generate property stub
Generate field stub
Generate method stub
Generate class
Generate interface
Generate new type (for a Class, Structure, Interface, Enum, Delegate, or Module)
The link below details using this feature.
This is a link to a great document covering the technical features of the Silverlight 4.
http://ecn.channel9.msdn.com/o9/learn/Silverlight4/Labs/Overview/WhatsNewInSilverlight4.xps
Microsoft has introduced client profile versions of the Net Framework (started in 3.5) which can cause some confusion for users. Below is a great post on what is new with client profiles.
http://blogs.msdn.com/jgoldb/archive/2009/05/27/net-framework-4-client-profile-introduction.aspx
If your running the VS2010 ultimate trial and running our of time you can extend the trial an additional 60 days by visiting this link;
This is a great complete training kit for getting started with Silverlight 4 from Scott Guthrie at Microsoft. This provides a great step by step introduction to silverlight development for line of business applications.
Link to Scott Gu’s blog.
http://weblogs.asp.net/scottgu/archive/2010/04/22/silverlight-4-training-kit.aspx
Link to training course.
Simplify your XML Comments!
GhostDoc is a free Visual Studio extension that automatically generates XML documentation comments for methods and properties based on their type, parameters, name, and other contextual information.
When generating documentation for class derived from a base class or for interface implementation (e.g. .NET Framework or your custom framework), GhostDoc will use the documentation that Microsoft or the framework vendor has already written for the base class or interface.
It supports VS2005, VS2008 and VS2010!
This is a good webpage on “Getting Started with Visual Studio 2010 Application Lifecycle Features”.
Another good development tool is UI Spy. This enables developers to view and interact with the US of an application and see the element interactions.
http://msdn.microsoft.com/en-us/library/ms727247(v=VS.85).aspx
While there is some administrative overhead in using FxCop and some of the constraints are questionable (many Microsoft assemblies fail all the checks) there is a lot of merit to using this tool.
http://msdn.microsoft.com/en-us/library/bb429473(VS.80).aspx
This is a great document on Dot Net coding guidelines.
http://dl.dropbox.com/u/5429585/Submain_DotNET_Coding_Guidelines.pdf
I found a good XML documentation comments guide.
I am trying to decide on a documentation utility for VB projects and am reviewing the following options;
1. Sandcastle, http://sandcastle.codeplex.com/
2. VBDocMan,http://www.helixoft.com/vsdocman/examples.html
3. Document X, http://www.innovasys.com/products/dx2008/overview.aspx
I have found that sandcastle does not support a jump in and use approach, lacks documentation and support.
I am reviewing VBDocMan and Document X. Any thoughts drop a comment. I will update once i have completed my review and made a decision.
Scott Guthrie (@scottgu) 4/21/10 7:47 PM I just did a blog post that talks about a bunch of small, but really nice, new VS 2010 debugger features: http://bit.ly/de1bxe |
Nlog is a great tool for logging with in VB.Net applications(http://nlog-project.org/). This post will discuss setting up nLog to write to both a local log file and a a SQL database.
First, we need to configure the log file;
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogFile="Nlog.log">
<targets>
<target name="file" xsi:type="File" layout="${longdate}|${level}|${callsite}|${logger}|${threadid}|${windows-identity:domain=false}--${message} ${exception:format=message,stacktrace:separator=*" fileName="c:\psnet\myapplication.log" />
<target name="database" type="Database">
<connectionString>
Data Source=databaseservername;Initial Catalog=databasename;User Id=username;Password=password;
</connectionString>
<commandText>
insert into system_logging(log_date,log_level,log_logger,log_message,log_machine_name, log_user_name, log_call_site, log_thread, log_exception, log_stacktrace) values(@time_stamp, @level, @logger, @message,@machinename, @user_name, @call_site, @threadid, @log_exception, @stacktrace);
</commandText>
<parameter name="@time_stamp" layout="${longdate}"/>
<parameter name="@level" layout="${level}"/>
<parameter name="@logger" layout="${logger}"/>
<parameter name="@message" layout="${message}"/>
<parameter name="@machinename" layout="${machinename}"/>
<parameter name="@user_name" layout="${windows-identity:domain=true}"/>
<parameter name="@call_site" layout="${callsite:filename=true}"/>
<parameter name="@threadid" layout="${threadid}"/>
<parameter name="@log_exception" layout="${exception}"/>
<parameter name="@stacktrace" layout="${stacktrace}"/>
</target>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="file"/>
<logger name="*" minlevel="Info" appendTo="database"/>
</rules>
</nlog>
There are a couple fields that need to be configured (in bold). One adjustment for testing is setting the (internalLogFile="Nlog.log"). This will assist us in debugging any database issues we have as this is nLog’s own log file.
Next, we need to created a matching database table;
/****** Object: Table [dbo].[system_logging] Script Date: 04/21/2010 17:05:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[system_logging](
[system_logging_guid] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[entered_date] [datetime] NULL,
[log_application] [varchar](200) NULL,
[log_date] [varchar](100) NULL,
[log_level] [varchar](100) NULL,
[log_logger] [varchar](8000) NULL,
[log_message] [varchar](8000) NULL,
[log_machine_name] [varchar](8000) NULL,
[log_user_name] [varchar](8000) NULL,
[log_call_site] [varchar](8000) NULL,
[log_thread] [varchar](100) NULL,
[log_exception] [varchar](8000) NULL,
[log_stacktrace] [varchar](8000) NULL,
CONSTRAINT [PK_system_logging] PRIMARY KEY CLUSTERED
(
[system_logging_guid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[system_logging] ADD CONSTRAINT [DF_system_logging_system_logging_guid] DEFAULT (newid()) FOR [system_logging_guid]
GO
ALTER TABLE [dbo].[system_logging] ADD CONSTRAINT [DF_system_logging_entered_date] DEFAULT (getdate()) FOR [entered_date]
GO
You must ensure that you give access to this table to the username you provide in the nLog configuration file.
In order to get emailed with error entries simple add this trigger to the system_logging table;
/****** Object: Trigger [dbo].[LogEmail] Script Date: 04/21/2010 17:06:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Justin Davis
-- Create date: 4/1/2008
-- Description: Send email of log message
-- =============================================
ALTER TRIGGER [dbo].[LogEmail]
ON [dbo].[system_logging]
AFTER insert
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
Declare @ToEmail varchar(100)
Declare @Title varchar(100)
Declare @logmessage varchar(8000)
declare @loglevel as varchar(100)
set @ToEmail = 'youremailaddress'
set @Title = 'Error'
set @loglevel = (select log_level from inserted)
set @logmessage = (select
'User Date:' + char(9) + char(9) + log_date + char(13) + char(10) +
'Computer:'+ char(9) + log_machine_name + char(13) + char(10) +
'User:' + char(9) + char(9) + log_user_name + char(13) + char(10) +
'Level:' + char(9)+ log_level + char(13) + char(10) +
'Logger:' + char(9)+ log_logger + char(13) + char(10) +
'Thread:'+ char(9) + log_thread + char(13) + char(10) +
'StackTrace:'+ char(9) + log_stacktrace + char(13) + char(10) +
'CallSite:'+ char(9) + log_call_site + char(13) + char(10) +
'Message:' + char(9) + log_message + char(13) + char(10) +
'Exception:'+ char(9) + log_exception as 'emailmessage'
from inserted)
if @loglevel <>'Info'
EXEC msdb.dbo.sp_send_dbmail @recipients=@ToEmail, @body= @logmessage, @subject = @Title, @profile_name = 'default'
END
Make sure that you configure SQL mail first. You might get an exception in the nlog.log file like this;
2010-04-21 13:53:02.0729 Error Target exception: System.Data.SqlClient.SqlException: The EXECUTE permission was denied on the object 'sp_send_dbmail', database 'msdb', schema 'dbo'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at NLog.Targets.DatabaseTarget.DoAppend(LogEventInfo logEvent)
at NLog.Targets.DatabaseTarget.Write(LogEventInfo logEvent)
at NLog.LoggerImpl.Write(Type loggerType, TargetWithFilterChain targets, LogEventInfo logEvent, LogFactory factory)
If so you it is because the username in the nlog.config file does not have access rights to the send mail SP. Run this script to fix.
EXEC msdb.dbo.sp_addrolemember @rolename = 'DatabaseMailUserRole'
,@membername = 'logger';
GO
References
Migrating to a new development IDE brings a number of issues when developing line of business applications. With all the exciting features in VS2010 we still have to consider issues like third party component issues, Net Framework 4 availability on client machines, mixing of development IDE’s (VS2008, VS2010) and many other minor issues.
Im my migration from VS2008 and Source Gear Fortress source control to VS2010 and team foundation 2010 I am making baby steps. First, I completed a long over due update to my Fortress source control (server and client) that addressed many existing bugs and brought VS2010 support. Second, I have decided to start using VS2010 for new server based applications where Framework 4 deployment is not as much of an issue. Third, I have delayed adopting team foundation server 2010 until the IDE migration is completed. This will allow me and my team time to get use to the IDE and test team foundation server.
Over the next few days I will be working on a few production projects using VS2010 targeting both 3.5SP1 and 4 frameworks using Fortress source control to test the waters. I am also getting use to team foundation server 2010 by running sample applications in VS2010 and using TFS for source control. This provides a nice test environment that allows me to get use to both VS2010 and TFS without compromising my production environment.
I started to use Windows Live Writer for posting to my blogger account and was getting this error when I tried to publish.
“The remote server returned an error: (403) Forbidden.”
Here is a great link on how to address the issue;
http://rebmordechaiwrites.blogspot.com/2009/12/how-to-configure-windows-live-writer.html