The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

Archive for May, 2011

Don’t sleep when you use your Entity Framework model from a separate assembly

Posted by jpluimers on 2011/05/05

The Entity Framework needs you to have a connection string in your App.Config.

It is good practice having your Entity Framework model in a separate assembly.

When using it in your main app, be aware that the connection string that belongs to your model needs to be in the App.config of your main app.

If not, you get an exception like this:

System.ArgumentException was unhandled
Message=The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.
Source=System.Data.Entity
StackTrace:
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.EntityClient.EntityConnection..ctor(String connectionString)
at System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)

The clue is the contents of the defaultContainerName parameter: you will see that in the App.config of your Entity Framework assembly.

Copy that over to the App.config of your main assembly, then make sure it points to your right database (if you use OTAP), then go :-)

Your App.config then looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="MyEntities" connectionString="metadata=res://*/My_EntityModel.csdl|res://*/My_EntityModel.ssdl|res://*/My_EntityModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=my-sql-server;initial catalog=my-database;persist security info=True;user id=my-user;password=my-password;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

–jeroen

Posted in .NET, C#, Database Development, Development, EF Entity Framework, Software Development, SQL Server | Leave a Comment »

SmackFu: Shoutcast Metadata Protocol

Posted by jpluimers on 2011/05/04

The SmackFu: Shoutcast Metadata Protocol page describes how the Icecast and Shoutcast meta-data (like song title) are being sent inside their streams.

Notes:

  • The above only explains the song meta data (artist-title); you cannot update the Stream Title without performing a reconnect, as they are in the stream meta data; this post explains why.
  • The stream headers are explained here, but they don’t contain the song title!
  • Icecast uses the dash “-” as separator between artist and title of the song, so if an Artist contains a dash, you are out of luck, as this thread shows.

–jeroen

Posted in .NET, BASS, Development, Power User, Software Development | Leave a Comment »

DealExtreme uses ASP.NET

Posted by jpluimers on 2011/05/03

It is always fun to see error messages on web-sites; they reveal a lot about the technology they use.

For instance, DealExtreme – a very popular site to order electronics and gadgets from the far east – uses ASP.NET.

They have verbose logging enabled, which even includes a warning to turn it off in production sits, as per this comment in the page source:

This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using <customErrors mode=”Off”/>. Consider using <customErrors mode=”On”/> or <customErrors mode=”RemoteOnly”/> in production environments.

This is the full text, indicating they use .NET 2.0 and SQL Server with connection pooling (which is a good thing), and the BLToolkit extensions, Callbacks, a separation of Business Logic and Data Abstraction (BLL, DAL/DAO) probably using Spring.net and Data Binding by calling BindData() in stead of DataBind().

Server Error in ‘/’ Application.


A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +578
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +88
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +6265031
   System.Data.SqlClient.SqlConnection.Open() +258
   BLToolkit.Data.DbManager.ExecuteOperation(OperationType operationType, Action operation) +64
[DataException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)]
   BLToolkit.Data.DbManager.OnOperationException(OperationType op, DataException ex) +176
   BLToolkit.Data.DbManager.ExecuteOperation(OperationType operationType, Action operation) +135
   BLToolkit.Data.DbManager.OpenConnection() +91
   BLToolkit.Data.DbManager.get_Connection() +42
   BLToolkit.Data.DbManager.OnInitCommand(IDbCommand command) +31
   BLToolkit.Data.DbManager.get_SelectCommand() +28
   BLToolkit.Data.DbManager.GetCommand(CommandAction commandAction, CommandType commandType, String sql) +18
   BLToolkit.Data.DbManager.PrepareCommand(CommandAction commandAction, CommandType commandType, String commandText, IDbDataParameter[] commandParameters) +91
   BLToolkit.Data.DbManager.SetCommand(CommandAction commandAction, CommandType commandType, String commandText, IDbDataParameter[] commandParameters) +51
   BLToolkit.Data.DbManager.SetCommand(String commandText, IDbDataParameter[] commandParameters) +25
   DealExtreme.Mall.Common.DAL.DAO.BLToolkitExtension.CategoryAccessor.GetAll() +168
   DealExtreme.Mall.Common.BLL.CategoryBL.CategoryLogic.GetAllCategory() +53
   DealExtreme.Mall.Common.Caching.ProductCaching.CategoryCache.GetAllCategories() +9
   DealExtreme.Mall.Common.Caching.ProductCaching.BLToolkitExtension.CategoryCache.GetAllCategories() +433
   DealExtreme.Mall.Search.BLL.SearchLogic.GetSearchedCategory(String request) +255
   DealExtreme.Mall.Search.Web.Search.BindData() +416
   DealExtreme.Mall.Search.Web.Search.Page_Load(Object sender, EventArgs e) +16
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +42
   System.Web.UI.Control.OnLoad(EventArgs e) +132
   System.Web.UI.Control.LoadRecursive() +66
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2428


[SqlException]: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at BLToolkit.Data.DbManager.ExecuteOperation(OperationType operationType, Action operation)
[DataException]: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
at BLToolkit.Data.DbManager.OnOperationException(OperationType op, DataException ex)
at BLToolkit.Data.DbManager.ExecuteOperation(OperationType operationType, Action operation)
at BLToolkit.Data.DbManager.OpenConnection()
at BLToolkit.Data.DbManager.get_Connection()
at BLToolkit.Data.DbManager.OnInitCommand(IDbCommand command)
at BLToolkit.Data.DbManager.get_SelectCommand()
at BLToolkit.Data.DbManager.GetCommand(CommandAction commandAction, CommandType commandType, String sql)
at BLToolkit.Data.DbManager.PrepareCommand(CommandAction commandAction, CommandType commandType, String commandText, IDbDataParameter[] commandParameters)
at BLToolkit.Data.DbManager.SetCommand(CommandAction commandAction, CommandType commandType, String commandText, IDbDataParameter[] commandParameters)
at BLToolkit.Data.DbManager.SetCommand(String commandText, IDbDataParameter[] commandParameters)
at DealExtreme.Mall.Common.DAL.DAO.BLToolkitExtension.CategoryAccessor.GetAll()
at DealExtreme.Mall.Common.BLL.CategoryBL.CategoryLogic.GetAllCategory()
at DealExtreme.Mall.Common.Caching.ProductCaching.CategoryCache.GetAllCategories()
at DealExtreme.Mall.Common.Caching.ProductCaching.BLToolkitExtension.CategoryCache.GetAllCategories()
at DealExtreme.Mall.Search.BLL.SearchLogic.GetSearchedCategory(String request)
at DealExtreme.Mall.Search.Web.Search.BindData()
at DealExtreme.Mall.Search.Web.Search.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
[HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown.
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.search_aspx.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955

Posted in .NET, ASP.NET, C#, Development, Software Development | Leave a Comment »

FAT32 formatting a HDD volume bigger than 32 gigabyte

Posted by jpluimers on 2011/05/02

Most external USB HDDs you buy are way bigger than 32 gigabyte, and factory formatted with NTFS.

Nowadays, many devices (TVs, modems, routers, etc) support attaching HDDs, but not all of them support NTFS, but most of them support FAT32.

My brother has such a TV. He has mental retardation (they have euphemisms for that; he basically has an IQ < 50, which in his means he can live on his own but needs daily visits from people that help him with the more complex things in life).

I’m his legal guardian (Dutch: curator), so my wife and me take care of some of those things.

This included getting his TV to recognize a USB HDD so he can watch his favourite TV series I recorded for him (Knight Rider, Top Gear, etc).

Windows NT and beyond cannot format FAT32 in an easy way.

They can from the commandline using the format command: use FOMAT X: /FS:FAT32 for that, it is slow and as soon as you add the /Q parameter to speed things up, it imposes the 32 gigabyte limit.

Microsoft suggests botting Windows 98 or Windows Me, but those have too many limitations (lack of USB support, no 48-bit LBA, imposing 137 gigabyte HDD limit, etc).

Luckily, Ridgecrop Consultants Ltd has a FAT32FORMAT tool  and accompanying GUI wrapper. They format any HDD using FAT32. Their tools work at least in Windows XP and up (I haven’t tested Windows 2000 and NT 4).

Problem solved: my brother can happily watch his favourite TV series I recorded for him :)

–jeroen

Posted in About, Personal, Power User, Windows, Windows 7, Windows Vista, Windows XP | Leave a Comment »