Exchange 2013 issues after CU9 - updates

I have a MS Exchange 2013 server that worked fine until I installed CU9 KB3087126.
Issues:
ECP is not accesible from the outside.
ECP is accessible from the inside using "https://server_name/ecp" but after entering the credentials I get a page with "Server Error in '/ecp' Application."
Could not load file or assembly 'Microsoft.Exchange.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=token_here' or one of its dependencies. The system cannot find the file specified.
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.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Exchange.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=token_here' or one of its dependencies. The system cannot find the file specified.
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.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Exchange.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=token_here' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileNotFoundException: Could not load file or assembly 'Microsoft.Exchange.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=token_here' or one of its dependencies. The system cannot find the file specified.]
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +153
System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +63
System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +124
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +76
>[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Exchange.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=token_here' or one of its dependencies. The system cannot find the file specified.]
System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +12425660
System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +69
System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +62
System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +299
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1262
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +133
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.Exchange.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=token_here' or one of its dependencies. The system cannot find the file specified.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12618996
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12458613
In the Event log I have a WARNING from ASP.NET 4.0.30319.0 with EventID 1310 saying:
Event code: 3008
Event message: A configuration error has occurred.
Event time: 7/20/2016 2:34:28 PM
Event time (UTC): 7/20/2016 11:34:28 AM
Event ID: a59d5b2b449a4b968766e110bc5704a6
Event sequence: 1
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/2/ROOT/ecp-12-131134880684035632
Trust level: Full
Application Virtual Path: /ecp
Application Path: C:\Program Files\Microsoft\Exchange Server\V15\ClientAccess\ecp\
Machine name: name_here
Process information:
Process ID: 11208
Process name: w3wp.exe
Account name: NT AUTHORITY\SYSTEM
Exception information:
Exception type: ConfigurationErrorsException
Exception message: Could not load file or assembly 'Microsoft.Exchange.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=token_here' or one of its dependencies. The system cannot find the file specified.
at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase)
at System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement)
at System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement)
at System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList)
at System.Web.HttpApplication.GetModuleCollection(IntPtr appContext)
at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)
>Could not load file or assembly 'Microsoft.Exchange.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=token_here' or one of its dependencies. The system cannot find the file specified.
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase)
Request information:
Request URL: https://localhost:444/ecp/exhealth.check
Request path: /ecp/exhealth.check
User host address: ::1
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\SYSTEM
Thread information:
Thread ID: 35
Thread account name: NT AUTHORITY\SYSTEM
Is impersonating: False
Stack trace: at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase)
at System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement)
at System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement)
at System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList)
at System.Web.HttpApplication.GetModuleCollection(IntPtr appContext)
at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)
In the Queue Viewer I have a lot of emails headed towards certain domains that are stuck with the error:
[{LRT=7/20/2016 2:40:17 PM};{LED=450 4.7.0 Proxy session setup failed on Frontend with '451 4.4.0 DNS query failed. The error was: DNS query failed with error ServerFailure'};{FQDN=correct_fqdn_here};{IP=correct_ip}]
What works:
OWA works from the inside and outside;
Apart from some emails to specific domains (small companies) inbound/outbound emails work from inside and outside of the company.(Tested with a Gmail account, testconnectivity.microsoft.com and received confirmation that emails from some big companies are being received - ex. hp.com)
Apart from the CU9 Update, nothing was changed prior to the update.
Searched the web a lot before asking but nothing helped. I'm guessing most of the issues are because ECP is not working.
Has anyone encountered this issue before and has an idea how to fix it?
Thanks in advance!

After a lot of research I ended up rebuilding the .net folders and AppPool entities in IIS. The main issue being that the IIS AppPools were not pointing to the correct ECP site, etc.
Now it works just fine.

Related

log4net.ext.json: ERROR Failed to find type [log4net.Layout.SerializedLayout, log4net.Ext.Json]

I've installed the nuget package for log4net.Ext.Json and following the first steps instructions from the wiki.
However, I am getting the following error at runtime:
log4net:ERROR Failed to find type [log4net.Layout.SerializedLayout, log4net.Ext.Json]
System.IO.FileNotFoundException: Could not load file or assembly 'log4net.Ext.Json' or one of its dependencies. The system cannot find the file specified.
File name: 'log4net.Ext.Json'
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Util.SystemInfo.GetTypeFromString(Assembly relativeAssembly, String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Util.SystemInfo.GetTypeFromString(String typeName, Boolean throwOnError, Boolean ignoreCase)
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint)
=== Pre-bind state information ===
LOG: DisplayName = log4net.Ext.Json
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: log4net.Ext.Json | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///<MyProject>/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: <MyProject>\bin\Debug\log4net-googlecloudlogging-console.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json.DLL.
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json/log4net.Ext.Json.DLL.
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json.EXE.
LOG: Attempting download of new URL file:///<MyProject>/bin/Debug/log4net.Ext.Json/log4net.Ext.Json.EXE.
log4net:ERROR Failed to create object to set param: layout
How can I fix this?
The dll log4net.Ext.Json.dll is missing in your output/running directory or the dll log4net.Ext.Json.dll does not contain the class log4net.Layout.SerializedLayout. First check the dll and if it is not there copy it to the directory.
I'd like to know what framework you compile with? That version was not .NetStandard ready. Now we have release 2.0.8 which includes it. Try to update and if it still doesn't work, update your Q with more context.

Local site intermittently can't connect to SQL Server while SSMS can

I am having the strangest problem: Everything was working fine while I was coding a new site I'm working on one night when suddenly the site could not longer connect to SQL Server. I can connect happily using SQL Server Management Studio, but the site throws the following exception.
Firewalls on this machine are completely disabled.
One issue thought is that I have SQL Server running under a local user I created. Some times when I restart the SQL Server Service to see if that resolves the problem, the service complains that the Login failed. I then re-enter the same credentials that got the service running in the first place, and then it starts up after AGAIN stating that the account has been granted login as a service rights. I have however tried using NETWORK SERVICES and LOCAL SYSTEM, both of which prompts the same exception from my site.
From time to time, however, it does work though. I'm running this on a domain connected notebook, so I'm wondering if this has something to do with it not being able to talk to the domain while I'm at home. The service account I created is however a local account.
I'm running this on IIS Express on Windows 8 Enterprise though (Just in case it's some known issue with Win8).
adding Pooling=no to the connection string also has no effect. [Ref]
Here is my connection string: Data Source=.;Initial Catalog=NotesBoard;Integrated Security=SSPI;
I've also used my Machine name instead on "." with the same outcome. Even tried FQDN.
System.Web.HttpException was unhandled by user code
HResult=-2147467259 Message=Unable to connect to SQL Server
database. Source=System.Web ErrorCode=-2147467259 WebEventCode=0
StackTrace:
at System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String
fullFileName, String dataDir, String connectionString)
at System.Web.DataAccess.SqlConnectionHelper.EnsureDBFile(String
connectionString)
at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String
connectionString, Boolean revertImpersonation)
at System.Web.Security.SqlRoleProvider.GetRolesForUser(String username)
at WebMatrix.WebData.SimpleRoleProvider.GetRolesForUser(String username)
at System.Web.Security.RolePrincipal.IsInRole(String role)
at ASP._Page_Views_Shared__Layout_cshtml.Execute() in d:\dtaylor\Documents\Visual Studio
2012\Projects\NotesBoard\NotesBoard\Views\Shared_Layout.cshtml:line
28
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.WebPages.WebPageBase.<>c__DisplayClass7.b__6(TextWriter
writer)
at System.Web.WebPages.HelperResult.WriteTo(TextWriter writer)
at System.Web.WebPages.WebPageBase.Write(HelperResult result)
at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action1 body)
at System.Web.WebPages.WebPageBase.PopContext()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext
pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter
filter, ResultExecutingContext preContext, Func1 continuation)
InnerException: System.Web.HttpException
HResult=-2147467259
Message=Unable to connect to SQL Server database.
Source=System.Web
ErrorCode=-2147467259
WebEventCode=0
StackTrace:
at System.Web.Management.SqlServices.GetSqlConnection(String server,
String user, String password, Boolean trusted, String
connectionString)
at System.Web.Management.SqlServices.SetupApplicationServices(String
server, String user, String password, Boolean trusted, String
connectionString, String database, String dbFileName, SqlFeatures
features, Boolean install)
at System.Web.Management.SqlServices.Install(String database, String dbFileName, String connectionString)
at System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String
fullFileName, String dataDir, String connectionString)
InnerException: System.Data.SqlClient.SqlException
HResult=-2146232060
Message=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: SQL Network Interfaces, error: 26 - Error Locating
Server/Instance Specified)
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=20
LineNumber=0
Number=-1
Server=""
State=0
StackTrace:
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean
ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean
trustServerCert, Boolean integratedSecurity, Boolean withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
serverInfo, String newPassword, SecureString newSecurePassword,
Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean
withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo
serverInfo, String newPassword, SecureString newSecurePassword,
Boolean redirectedUserInstance, SqlConnectionString connectionOptions,
SqlCredential credential, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer
timeout, SqlConnectionString connectionOptions, SqlCredential
credential, String newPassword, SecureString newSecurePassword,
Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential
credential, Object providerInfo, String newPassword, SecureString
newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection
owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions
userOptions)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1
retry)
at System.Data.SqlClient.SqlConnection.Open()
at System.Web.Management.SqlServices.GetSqlConnection(String server,
String user, String password, Boolean trusted, String
connectionString)
InnerException:
Update:
This error is more clearly defined in a new post here
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.
Looks like a network problem between the web server and the SQL server. Could be anything: firewall, DNS, ... Could also be intermittent problems with your SQL server.
Talk to your system administrator for more details. There's nothing wrong with your code.

Fatal error encountered during data read

I am doing a regular update table scan
Using connect1 As New MySqlConnection(ConnectLocalhost.serverString)
connect1.Open()
Dim cmd = New MySqlCommand("set net_write_timeout=99999; set net_read_timeout=99999", connect1) ' // Setting tiimeout on mysqlServer
cmd.ExecuteNonQuery()
Dim BusinessReader = selectSomeQuery("Select * from tablebusiness limit 800,10000000", connect1)
Do While BusinessReader.Read 'random exception here
Sometimes I got this error
MySql.Data.MySqlClient.MySqlException was unhandled
ErrorCode=-2147467259
Message=Fatal error encountered during data read.
Number=0
Source=MySql.Data
StackTrace:
at MySql.Data.MySqlClient.MySqlDataReader.Read()
at dreamhost.Business.InsertLocalhost() in \\work\c\business\fromwork\currentprojects\program\library\vb.net\badger.vb:line 1849
at dreamhost.Business.surFoursquare() in \\work\c\business\fromwork\currentprojects\program\library\vb.net\badger.vb:line 1939
at dreamhost.traverseweb._Lambda$__92() in \\work\c\business\fromwork\currentprojects\program\library\vb.net\traverseweb.vb:line 77
at dreamhost.buttonClicking.startAndStopClickingButton(Object sender, Action SomeSub) in \\work\c\business\fromwork\currentprojects\program\library\vb.net\buttonclicking.vb:line 45
at dreamhost.traverseweb.foursquare_Click(Object sender, EventArgs e) in \\work\c\business\fromwork\currentprojects\program\library\vb.net\traverseweb.vb:line 77
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.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(ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at dreamhost.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
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: MySql.Data.MySqlClient.MySqlException
ErrorCode=-2147467259
Message=Reading from the stream has failed.
Number=0
Source=MySql.Data
StackTrace:
at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.FetchDataRow(Int32 statementId, Int32 columns)
at MySql.Data.MySqlClient.Driver.FetchDataRow(Int32 statementId, Int32 columns)
at MySql.Data.MySqlClient.ResultSet.GetNextRow()
at MySql.Data.MySqlClient.ResultSet.NextRow(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlDataReader.Read()
InnerException: System.IO.IOException
Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Source=MySql.Data
StackTrace:
at MyNetworkStream.HandleOrRethrowException(Exception e)
at MyNetworkStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)
at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
InnerException: System.Net.Sockets.SocketException
ErrorCode=10054
Message=An existing connection was forcibly closed by the remote host
NativeErrorCode=10054
Source=System
StackTrace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
InnerException:
All I want is for the program to just "continue" when this thing happen. But that seems to be impossible. So I guess I need a way to make sure this bug doesn't happen. It happens randomly eery 800 entries or so.
Looks to me the connection is forcibly closed by remote host. In that case, I simply want to go where things left on and restart again.
There may be a lot of reasons why the connection drops (server load, network problem, etc). That your program is crashing suggests that your database code is not protected by a try statement. If you do something like this :
try
Using connect1 As New MySqlConnection(ConnectLocalhost.serverString)
connect1.Open()
Dim cmd = New MySqlCommand("set net_write_timeout=99999; _
set net_read_timeout=99999", connect1)
cmd.ExecuteNonQuery()
Dim BusinessReader = selectSomeQuery("Select *...", connect1)
Do While BusinessReader.Read
'random exception here'
'...more code'
Loop
End Using
Catch ex As Exception
' code breaks here on exception - recover from this point '
End Try
I won't go into a protracted dissertation on exception handling but there are a lot of resources out there if you have a look. How you deal with it will depend on your specific situation - whether to log the exception, record what the last successful operation was, whether to try to resume from where you were or whether to try to do the whole thing over again, notify the user, etc.
MSDN - Try/Catch/Finally

Sql CLR runtime error

Doing a SQL CLR. Everything worked great in development, everything whent great in testing, then we went live, and everything broke. So it seems to have something to do with EXTERNAL_ACCESS security. I have confirmed that our database is marked as trustworthy, the database owner is a sysadmin, and the assembly is marked as EXTERNAL_ACCESS permissions. That leaves me a bit stumpted as to what could cause this error. Any other ideas on what could cause this error?
(I hid a few things that arnt critical to the error)
Error querying repository for dirty items: 'prc_XXXXXXXXXXXXXXXXXXXXX'
System.Data.SqlClient.SqlException: An error occurred in the Microsoft .NET Framework while trying to load assembly id 65536. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error:
System.IO.FileLoadException: Could not load file or assembly 'myassemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=123451234151234' or one of its dependencies. Exception from HRESULT: 0x80FC3C2C
System.IO.FileLoadException:
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
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.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
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.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at ....
For some reason, even though the UI showed that the assembly had external access permissions (and it added to the database with those permissions), internally it must have thought that it didnt have that kind of access for some reason. So as a work around I ran these commands and it fixed the problem (note I tried running just the second command, and it didnt fix it):
ALTER ASSEMBLY [< AssemblyName>]
WITH PERMISSION_SET = UNSAFE
ALTER ASSEMBLY [< AssemblyName>]
WITH PERMISSION_SET = EXTERNAL_ACCESS

Get FileNotFoundException error when call a ActiveX in SSIS script task

I need call a ActiveX in my SSIS package, so I use script task and write the following C# script:
public void Main()
{
clsAptFdbReader objFdbReader = new clsAptFdbReader("UnitedStates20000830.fdb");
objFdbReader.OpenFdb(false);
Dts.TaskResult = (int)ScriptResults.Success;
}
Get a error:
Error:
System.Reflection.TargetInvocationException:
Exception has been thrown by the
target of an invocation. --->
System.IO.FileNotFoundException: Could
not load file or assembly
'Interop.APTFDBReader,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its
dependencies. The system cannot find
the file specified. File name:
'Interop.APTFDBReader,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' at
ST_320325ad8e2543f09ee688d809f58ee7.csproj.ScriptMain.Main()
=== Pre-bind state information === LOG: User = SHINETECHCHINA\xugy LOG:
DisplayName = Interop.APTFDBReader,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null (Fully-specified)
LOG: Appbase = file:///C:/Program
Files/Microsoft SQL
Server/100/DTS/binn/ LOG: Initial
PrivatePath = NULL Calling assembly :
(Unknown).
=== LOG: This bind starts in default load context. LOG: Using application
configuration file: C:\Program
Files\Microsoft SQL
Server\100\DTS\binn\DtsDebugHost.exe.Config
LOG: Using machine configuration file
from
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to
reference at this time (private,
custom, partial, or location-based
assembly bind). LOG: Attempting
download of new URL file:///C:/Program
Files/Microsoft SQL
Server/100/DTS/binn/Interop.APTFDBReader.DLL.
LOG: Attempting download of new URL
file:///C:/Program Files/Microsoft SQL
Server/100/DTS/binn/Interop.APTFDBReader/Interop.APTFDBReader.DLL.
LOG: Attempting download of new URL
file:///C:/Program Files/Microsoft SQL
Server/100/DTS/binn/Interop.APTFDBReader.EXE.
LOG: Attempting download of new URL
file:///C:/Program Files/Microsoft SQL
Server/100/DTS/binn/Interop.APTFDBReader/Interop.APTFDBReader.EXE.
--- End of inner exception stack
trace --- at
System.RuntimeMethodHandle._InvokeMethodFast(Object
target, Object[] arguments,
SignatureStruct& sig, MethodAttributes
methodAttributes, RuntimeTypeHandle
typeOwner) at
System.RuntimeMethodHandle.InvokeMethodFast(Object
target, Object[] arguments, Signature
sig, MethodAttributes
methodAttributes, RuntimeTypeHandle
typeOwner) at
System.Reflection.RuntimeMethodInfo.Invoke(Object
obj, BindingFlags invokeAttr, Binder
binder, Object[] parameters,
CultureInfo culture, Boolean
skipVisibilityChecks) at
System.Reflection.RuntimeMethodInfo.Invoke(Object
obj, BindingFlags invokeAttr, Binder
binder, Object[] parameters,
CultureInfo culture) at
System.RuntimeType.InvokeMember(String
name, BindingFlags bindingFlags,
Binder binder, Object target, Object[]
providedArgs, ParameterModifier[]
modifiers, CultureInfo culture,
String[] namedParams) at
System.Type.InvokeMember(String name,
BindingFlags invokeAttr, Binder
binder, Object target, Object[] args,
CultureInfo culture) at
Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
You can generate the interop as part of your build using TLBIMP.EXE, and give it arguments to build a strong name.
I'm not sure if it's wise to install that interop into the GAC, though, if it's based on a third-party COM server?