Pages

Showing posts with label Errors. Show all posts
Showing posts with label Errors. Show all posts

Tuesday, November 10, 2015

This application is currently offline. To enable the application, remove the app_offline.htm file from the application root directory.

This application is currently offline. To enable the application, remove the app_offline.htm file from the application root directory.
 I was getting this error in Visual Studio 2013 when trying to debug my app.  There was no app_offline.htm file in my Solution Explorer, but if I did a Open folder in file explorer, there it was.

Just delete it.
...

Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Wednesday, November 13, 2013

The type or namespace name 'OfficeOpenXml' could not be found

Error Message:
The type or namespace name 'OfficeOpenXml' could not be found (are you missing a using directive or an assembly reference?)

You need to change your app config to use .NET Framework 4 not .NET Framework 4 (Client Profile).

Project - <Project> Properties - Application tab

Target Framework

As it turns out, EPPlus needs the System.Web namespace, which is not in the client profile.



...

Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Monday, January 14, 2013

Cannot execute as the database principal.

Cannot execute as the database principal because the principal "username" does not exist, this type of principal cannot be impersonated, or you do not have permission.
I am going to read your mind now.

  1. You recently backed up your database copy-only and moved it to another server or development box. 
  2. You're attempting to perform an  "Execute As..." command.
  3. Your software has been running for some time and this new error just started cropping up after you "refreshed" your copy of the database (from production?).
  4. You looked at the server logins, and the database users, and they seem to match (there is a login with the same name as the user).
What happened is that the SIDs (Security IDs) from the server login does not match the database user of the same name.  Remember that LOGINS are stored at the server level and USERS are in the databases.

What you need to do is re-create the user in the database (and reassign any roles and permissions).

USE [myDB]
GO

/****** Object:  User [myUser]    Script Date: 01/14/2013 18:21:22 ******/
IF  EXISTS (SELECT * FROM sys.database_principals WHERE name = N'myUser')
DROP USER [myUser]
GO

USE [myDB]
GO

/****** Object:  User [myUser]    Script Date: 01/14/2013 18:21:22 ******/
GO

CREATE USER [myUser] FOR LOGIN [myUser] WITH DEFAULT_SCHEMA=[dbo]
GO




...

Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Tuesday, December 4, 2012

Operation is not valid due to the current state of the object.

App Details:

Visual Studio 2010
Desktop Winforms App
MDI Child form with a Datagridview connected to SQL Server 2008

Error details:
When closing the form, debugger jumps to this line in form.designer.cs (one of the files you are not supposed to edit).

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
    if (disposing && (components != null))
    {
        components.Dispose();  //<<<---error points here
    }
    base.Dispose(disposing);
}
and here is the massive error...

System.InvalidOperationException was unhandled
  Message=Operation is not valid due to the current state of the object.
  Source=System.Windows.Forms
  StackTrace:
       at System.Windows.Forms.DataGridViewCell.GetInheritedStyle(DataGridViewCellStyle inheritedCellStyle, Int32 rowIndex, Boolean includeColors)
       at System.Windows.Forms.DataGridViewCell.GetPreferredWidth(Int32 rowIndex, Int32 height)
       at System.Windows.Forms.DataGridViewColumn.GetPreferredWidth(DataGridViewAutoSizeColumnMode autoSizeColumnMode, Boolean fixedHeight)
       at System.Windows.Forms.DataGridView.AutoResizeColumnInternal(Int32 columnIndex, DataGridViewAutoSizeColumnCriteriaInternal autoSizeColumnCriteriaInternal, Boolean fixedHeight)
       at System.Windows.Forms.DataGridView.OnColumnGlobalAutoSize(Int32 columnIndex)
       at System.Windows.Forms.DataGridView.OnColumnCommonChange(Int32 columnIndex)
       at System.Windows.Forms.DataGridViewCell.OnCommonChange()
       at System.Windows.Forms.DataGridViewComboBoxCell.set_DataSource(Object value)
       at System.Windows.Forms.DataGridViewComboBoxCell.DataSource_Disposed(Object sender, EventArgs e)
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.ComponentModel.Component.Dispose(Boolean disposing)
       at System.Windows.Forms.BindingSource.Dispose(Boolean disposing)
       at System.ComponentModel.Component.Dispose()
       at System.ComponentModel.Container.Dispose(Boolean disposing)
       at System.ComponentModel.Container.Dispose()
       at Onesource.MaterialReceiptsEntry.Dispose(Boolean disposing) in P:\Projects\myproject\sample\MaterialReceiptsEntry.Designer.cs:line 18
       at System.Windows.Forms.Form.WmClose(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DefMDIChildProc(IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at System.Windows.Forms.Form.DefWndProc(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmSysCommand(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DefMDIChildProc(IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at System.Windows.Forms.Form.DefWndProc(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmNcButtonDown(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at Onesource.Program.Main() in P:\Projects\myproject\sample\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:
The solution:
I was looking through the ugly error stack above and found a lot of references to stuff like GetPreferredWidth. Having previously dealt with numerous problems involving AutoSizeColumnsMode and DataGridViewComboboxColumns,   I decided to try testing the form with AutoSizeColumnsMode set to None.  The layout did suck, but the form stopped crashing...

This means that the datagridview is trying to resize its columns during a form close!  Here is what I did to solve the problem.

I set the AutoSizeColumnsMode to AllCells and added a FormClose event as follows...




private void MaterialReceiptsEntry_FormClosing(object sender, FormClosingEventArgs e)

{

myDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;

}

This ensures that the grid will not be updating its column sizes as the form is closing.



...

Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Thursday, November 29, 2012

Case Schizophrenia and the DataGridViewComboboxColumn

So by default SQL Server (Microsoft) creates indices* and  does searches that are case insensitive.

Select * from orders where salesrep='bob' Will find BOB, bob, bOb, etc. (but not Robert)

So I have a DataGridViewComboboxColumn for that field, but since the data all comes from Paradox, where anything goes, I have a mixture of case scenarios.

As it turns out, even though your database cares not what capitalization you use, the combobox does.  It WILL NOT MATCH a field that has an alternate capitalization of whats in your data.

Example: if you have DONNA in the lookup list, and Donna in the orders table, the dropdown will display SOME RANDOM OTHER NAME.

It also throws a dataerror that looks like...

Order Entry [OrdersGrid]: Row 2 Column 16 Context Formatting, PreferredSize... System.Windows.Forms.DataGridViewDataErrorEventArgs DATA: TONYA 

...and it throws this error for each and every row you attempt to display on the screen.

The solution?

All I did was load the Purchase Orders table using the salesman as its own lookup.  like this

update Purchase_Order set Salesman=(select Salesman from Salesman S where S.Salesman=Purchase_Order.Salesman)

So, we're looking up the salesman, say "Bob" in the Salesman lookup table (finding, say "BOB") and writing that back over the Bob in the row, essentially updating the names in such a way as to match exactly what's in the lookup table.

Now our DataGridViewComboboxColumns work, and we didn't even have to edit the program!




...
* I still can't make myself use the word indexes.

Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Monday, January 16, 2012

[INTERSOLV][ODBC Paradox driver][Paradox]Network initialization failed.

If you're seeing a...

[INTERSOLV][ODBC Paradox driver][Paradox]Network initialization failed.

... or a ...

[INTERSOLV][ODBC Paradox driver][Paradox]Directory is controlled by other .NET file.

... message, you're probably  trying to connect an ASP.NET or VS.NET Program to a Paradox database.

You've been all over the internet and there is some stuff about not being able to work on a SUBST path, but nothing you try works.  If you use the SUBST path you get Network initialization failed, while using the real path gives Directory is controlled by other .NET file.


...

Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Tuesday, August 30, 2011

Version Number Fail

So...
I'm building a Windows desktop application and noticed that the version number (after 50+ builds) is 1.0.0.0.  So I looked for "Auto increment assembly version and came across this great article.
Ok.
So if you open /Properties/AssemblyInfo.cs you see the following lines...

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
So I changed it to...
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.*")]

And what happened?  Well for one, it causes this line (elsewhere in my code) to FAIL.
string path = Application.CommonAppDataPath;
...thows the error:
System.ArgumentException was unhandled
  Message=Illegal characters in path.
  Source=mscorlib
  StackTrace:
       at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)
Apparently, CommonAppDataPath doesn't look at the built version number, it looks at the text in AssemblyInfo.cs.  That's just great! 

Dearest Microsoft.  Please don't tease us with these 'features' that aren't.

The real solution to this would be twofold.
  1. Make the CommonAppDataPath read the App version as built during the last compile.
  2. Make another AppDataPath that does not include the version.


Bryan Valencia is a contributing editor and founder of Visual Studio Journey.  He owns and operates Software Services, a web design and hosting company in Manteca, California.

Monday, February 2, 2009

"Server Application Unavailable"

I got this error message while trying to set up my on line site to use a different database from the default crap-tastic AspNetSqlProvider that takes 3 minutes to boot up with each web hit.
Here's the entire (incorrect) error message as IIS sends it.

Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable.  Please hit the "Refresh" button in your web browser to retry your request.
Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.
The first clue I got that something was Micro-softy was that there was no event logged in the event logger. I think I may have caused this problem when I logged in to the server with Remote Desktop and with Visual Web Developer at the same time, trying to make it select the correct database.

The Solution

  1. go to the webserver (or remote-desktop in)
  2. open IIS Manager (Microsoft Internet Information Services)
  3. browse to the server and website that is broken
  4. stop the website
  5. open the site's properties page (right click the name of the site and pick "properties")
  6. select the ASP.NET tab and change the .net version. Click Apply.
  7. change the version back to the right (latest) version. Click Apply.
  8. close the properties page and restart the website.

Tuesday, March 11, 2008

IE7 Displays Blank Page: Firefox OK.

When I try to browse to my website, which contins an ASP page, I get a blank page for IE7, yet all is well for Firefox.

View Source in Firefox gives the normal page, while IE just shows this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; 
charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

The page had some Flash embedded, but I get this result even after removing it. Im heading for "Clearly, IE is BROKEN". What MORON would have a browser substitute a blank page without any kind of error or warning message?


I found the solution after pulling an all-nighter on it.

This had to do with a database error: here's what happened. For some reason the database error was NOT getting reported to the browser, it just got a blank page.

I store the data from every hit in a table for diagnosing problems. That data element was a varchar(250), which up until now was more than adequate. The string from a firefox hit comes in at 163 and looks like this:

03/10/2008 16:24:14 Mozilla Netscape 5.0 (Windows; en-US) Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12 en-US Win32

However IE7 sends this for the exact same page:

03/10/2008 16:24:14 Mozilla Microsoft Internet Explorer 4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.590; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022) Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.590; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022) undefined Win32

That's a whopping 380 characters, which caused a string length error on my SQL insert command.

I still don't understand why in hell it returned a completely blank page to IE without any errors listed but whatever, I'm re-doing the whole site in ASP.NET anyways.

The ANSWER: I had to stretch the database column where I'm storing the hit data strings to 1000 characters. That ought to hold me until IE8 SP2 at least.

Monday, September 17, 2007

Microsoft, your Help is Crap!

Ok, I want to use asp.net to build a simple email form that send me an email whenever someone wants to contact me from my website. I figured that after all the easy-login stuff on the toolbar, there would be some kind of ready-made gizmo.

There isn't

Furthermore, when you use the trusty F1, and type asp email form tutorial or simple form tutorial, you get nothing but totally irrelevant crap from the results screen.

So I googled it and ALL the results fall into one of 2 categories.

  1. downloadable components
  2. vb.net

What the hell?

So here I am writing like 300 lines of code, and I know it HAS TO BE easier than this... why is it any harder than this?

smtp.send(
 mailmessage(
  request.querystrings("to").tostring(),
  request.querystrings("from").tostring(),
  request.querystrings("subject").tostring(),
  request.querystrings("body").tostring()
 )
)

Why, indeed?

Thursday, August 30, 2007

ASP.NET 2008 Beta: '"SqlDataSource1";' could not be found.

When you get this error in Visual Web Developer 2008 Beta:

The DataSourceID of 'GridView1' must be the ID of a control of type IDataSource. A control with ID '"SqlDataSource1";' could not be found.

do this:

Find the Code that looks like this:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource1"; EmptyDataText="There are no data records to display." GridLines="Vertical"

...and remove the semicolon (;).

Share This!

Contact Us

Name

Email *

Message *