Elmah.MVC - MVC 5 ArgumentNullException: Value cannot be null. Parameter name id: - sql-server

I am receiving an error when trying to render the elmah error logs and using SQL DB. "http://localhost:5525/elmah" [ArgumentNullException: Value cannot be null.
Parameter name: id]
Elmah.ErrorLogEntry..ctor(ErrorLog log, String id, Error error) in c:\builds\ELMAH-1.2-SP2\src\Elmah\ErrorLogEntry.cs:57
Elmah.SqlErrorLog.ErrorsXmlToList(XmlReader reader, IList errorEntryList) in c:\builds\ELMAH-1.2-SP2\src\Elmah\SqlErrorLog.cs:365
Elmah.SqlErrorLog.ErrorsXmlToList(String xml, IList errorEntryList) in c:\builds\ELMAH-1.2-SP2\src\Elmah\SqlErrorLog.cs:332
Elmah.SqlErrorLog.GetErrors(Int32 pageIndex, Int32 pageSize, IList errorEntryList) in c:\builds\ELMAH-1.2-SP2\src\Elmah\SqlErrorLog.cs:186
Elmah.ErrorLogPage.OnLoad(EventArgs e) in c:\builds\ELMAH-1.2-SP2\src\Elmah\ErrorLogPage.cs:76
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
I have the latest Core Elmah 1.2-SP2 and the latest Elmah.MVC 2.1.2. I installed the Nuget package Elmah.MVC with default web.config settings.
When I configure web.config to log errors to the database the errors are recorded in the database but I can't render the error page. When I don't configure the database the elmah page renders just fine.
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="Company" />
</elmah>
Decompiling Elmah I see in the constructor where the argument is thrown.
if (id == null)
throw new ArgumentNullException("id");
if (id.Length == 0)
throw new ArgumentException((string) null, "id");
All my ErrorId's in the database are populated GUIDs.
I am stumped as to what id is not being passed to the core elmah. Has anyone ran into this before?

I downloaded the core Elmah code and stepped through to find in SqlErrorLog.cs, method ErrorsXmlToList(XmlReader reader, IList errorEntryList) there is a call to get id which was the parameter missing: string id = reader.GetAttribute("errorId"); I lower cased "errorid" and everything worked. Obviously this is not a good solution because this is core code that everyone works with so I dug deeper.
This led me to look at stored procedure ELMAH_GetErrorsXml. I found in our database we had a lower case "errorid". I updated the stored procedure to select "errorId" and changed the core Elmah back to the original code and of course everything worked.

Related

How to use Hangfire in ASP.NET Core with Azure database and Active Directory Password authentication

We're trying our first use of Hangfire (v1.7.19) in an ASP.NET Core WebApi application (.NET 5). Previously they've all been old school ASP.NET, and have worked without issue.
Hangfire packages used (per the Hangfire documentation) are Hangfire.Core, Hangfire.SqlServer and Hangfire.AspNetCore. We've also tried to just use the combined Hangfire package, but are having the same results.
Lifting directly from the code on that documentation page, in ConfigureServices we add
services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(connectionString), new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
DisableGlobalLocks = true
}));
which, at runtime, gives
System.ArgumentException
HResult=0x80070057
Message=Keyword not supported: 'authentication'.
Source=System.Data.SqlClient
StackTrace:
at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary`2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms)
at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms)
at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
at System.Data.SqlClient.SqlConnection..ctor(String connectionString)
at Hangfire.SqlServer.SqlServerStorage.<.ctor>b__6_0()
at Hangfire.SqlServer.SqlServerStorage.CreateAndOpenConnection()
at Hangfire.SqlServer.SqlServerStorage.UseConnection[T](DbConnection dedicatedConnection, Func`2 func)
at Hangfire.SqlServer.SqlServerStorage.UseConnection(DbConnection dedicatedConnection, Action`1 action)
at Hangfire.SqlServer.SqlServerStorage.Initialize()
at Hangfire.SqlServer.SqlServerStorage..ctor(String nameOrConnectionString, SqlServerStorageOptions options)
at Hangfire.SqlServer.SqlServerStorage..ctor(String nameOrConnectionString)
at Hangfire.SqlServerStorageExtensions.UseSqlServerStorage(IGlobalConfiguration configuration, String nameOrConnectionString)
The value of connectionString is
Initial Catalog=XXX;Data Source=YYY;Authentication=Active Directory Password;UID=ZZZ;PWD=PPP"
This works fine with local SqlServer and LocalDb, but not with AzureDB. The connection string is exactly the one we're also using for EntityFrameworkCore 5 (in fact, the value is assigned from context.Database.GetConnectionString()).
I've read where there were issues with AzureDB and .NET Core, but those were resolved quite some time ago. Looking through the Hangfire.SqlServer package dependencies, I see where it uses System.Data.SqlClient, and current documentation for AzureDB use all refer to Microsoft.Data.SqlClient, which makes me think that the enhancements to support Active Directory Password authentication weren't made in System.Data.SqlClient but only in the newer Microsoft.Data.SqlClient package. If that's the case, I can put in a request that Hangfire replace its SqlClient package, but want to get confirmation before I do that.
Any ideas if this is indeed the case? Is there something we can do in the meantime to fix this instead?
Thanks in advance.
Hangfire IO GitHub Issue 1827
Pointers from Sergey Odinokov
As early as 1.7.8 there has been support to use an overload of UseSqlServerStorage that accepts a Func<DbConnection> instead of a connection string where you can use a connection factory to provide the newer Microsoft.Data.SqlClient.SqlConnection which supports the Authentication keyword.
Here is the related source code
You can use this like
services.AddHangfire(config => config
// other options you listed above removed for brevity
.UseSqlServerStorage(
() => new Microsoft.Data.SqlClient.SqlConnection(<connection_string>)
, new SqlServerStorageOptions() {...}
)
);

System.ArgumentException: An entry with the same key already exists. in sssi pack

I deploy the pack from ssis to SSISD, and try to create agent job to run the package.
after deploy to SSMS, getting the error
System.ArgumentException: An entry with the same key already exists.
===================================
An entry with the same key already exists. (System)
Program Location:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.TreeSet1.AddIfNotPresent(T item)
at System.Collections.Generic.SortedDictionary2.Add(TKey key, TValue value)
at Microsoft.SqlServer.Management.Sdk.Sfc.SfcCollatedDictionaryCollection3.AddShadow(T obj)
at Microsoft.SqlServer.Management.Sdk.Sfc.SfcCollection3.Microsoft.SqlServer.Management.Sdk.Sfc.ISfcCollection.AddShadow(SfcInstance sfcInstance)
at Microsoft.SqlServer.Management.Sdk.Sfc.SfcInstance.CreateNewObjectFromRow(ISfcCollection childColl, IDataReader reader)
at Microsoft.SqlServer.Management.Sdk.Sfc.SfcInstance.InitObjectsFromEnumResultsRec(ISfcCollection childColl, IDataReader reader, Int32 columnIdx, Object[] parentRow)
at Microsoft.SqlServer.Management.Sdk.Sfc.SfcInstance.InitObjectsFromEnumResults(ISfcCollection childColl, IDataReader reader)
at Microsoft.SqlServer.Management.Sdk.Sfc.SfcInstance.InitChildLevel(ISfcCollection childColl)
at Microsoft.SqlServer.Management.Sdk.Sfc.SfcCollection3.InitializeChildCollection(Boolean refresh)
at Microsoft.SqlServer.Management.Sdk.Sfc.SfcCollection3.EnsureCollectionInitialized()
at Microsoft.SqlServer.Management.Sdk.Sfc.SfcCollection3.Microsoft.SqlServer.Management.Sdk.Sfc.ISfcCollection.EnsureInitialized()
at Microsoft.SqlServer.Management.IntegrationServices.PackageInfo.get_Parameters()
at Microsoft.SqlServer.IntegrationServices.UITasks.ExecuteDataProvider.AddParametersDataGridToDataBus()
at Microsoft.SqlServer.IntegrationServices.UITasks.ExecuteDataProvider.AddToDataBus()
at Microsoft.SqlServer.IntegrationServices.UITasks.PropertiesDataProvider.Initialize(ITaskManager taskManager, IPropertyDictionary properties)
at Microsoft.SqlServer.Management.TaskForms.TaskManager.InitializeTaskFormComponent(Object component, ITaskFormComponentInfo info)
at Microsoft.SqlServer.Management.TaskForms.TaskFormManager.InitializeTaskFormComponent(Object component, ITaskFormComponentInfo info)
at Microsoft.SqlServer.Management.TaskForms.TaskManager.InitializeTaskFormComponents(IList1 taskFromComponentsInfo)
at Microsoft.SqlServer.Management.TaskForms.TaskFormManager.InitializeTaskFormComponents(IList1 taskFromComponentsInfo)
at Microsoft.SqlServer.Management.TaskForms.TaskManager.Initialize(String moniker, IContext context, IList1 taskFromComponents)
at Microsoft.SqlServer.Management.TaskForms.TaskFormManager.Initialize(String moniker, IContext context, ITaskFormInfo taskFormInfo)
at Microsoft.SqlServer.Management.TaskFormFactoryService.CreateTaskFormInstance(String taskFormMoniker, IContext context)
at Microsoft.SqlServer.Management.ActionHandlers.ShowTaskUIDialogActionHandler.RunTaskForm(IContext context)
at Microsoft.SqlServer.Management.ActionHandlers.DialogBasedActionHandler.RunTaskFormThread(Object contextObject)
Please help to fix it
This looks to be an error that one encounters when deploying SSIS packages having connection managers not in sync i.e. if a connection manager is changed as 'project connection manager' and this change is not reflected in the other packages using the same connection manager. Refer to the link for more details.
This issue has been occurred due to same connection name used for multiple packages.
Solution: Check which connections name are same for multiple packages .
Change the duplicate connection names and then Build and Deploy..
It worked for me :)

EPiServer Error during import: System.ArgumentException: Cannot be the same as destination

I am trying to import content from our UAT server to our Production server.
The Production database was originally cloned from the UAT database, both code bases are the same.
My procedure when exporting/importing is really straight forward, first: http://screencast.com/t/UkT1W7t7g
Then I get the final file (7MB+) with all the content from UAT, then I go to Production and select the following: http://screencast.com/t/UkT1W7t7g
When clicking on import I get the following error: http://screencast.com/t/lgr7jeFX
This is what I get in the error log:
2016-11-28 10:31:04,995 [5] ERROR EPiServer.Core.Transfer.TransferLogger: 10.5.3 Export/import error: Exception: Cannot be the same as destination
Parameter name: contentLinkID
System.ArgumentException: Cannot be the same as destination
Parameter name: contentLinkID
at EPiServer.DataAccess.ContentSaveDB.Move(Int32 contentLinkID, Int32 destinationLinkID, Boolean archive)
at EPiServer.DataAbstraction.ContentStore.Move(Int32 contentLink, Int32 destinationLinkID, Boolean archive)
at EPiServer.DefaultContentProvider.Move(ContentReference contentReference, ContentReference destinationLink)
at EPiServer.Core.Transfer.ContentTransfer.MoveContent(IContent content, ContentReference parentLink, AccessLevel requiredDestinationAccess)
at EPiServer.Core.Transfer.ContentTransfer.Import(RawContent rawContent, AccessLevel requiredDestinationAccess, Guid& importedPageGuid)
at EPiServer.Core.Transfer.ContentTransfer.Import(ITransferContentData content, AccessLevel requiredDestinationAccess)
at EPiServer.Enterprise.DataImporter.ImportContents[T](XmlTextReader reader, ZipPackage package)
at EPiServer.Enterprise.DataImporter.ImportStream(ZipPackage package, XmlTextReader reader, String partName)
at EPiServer.Enterprise.DataImporter.ImportPartOfPackage(ZipPackage package, String partName)
at EPiServer.Enterprise.DataImporter.ImportRaw(ZipPackage package)
at EPiServer.Enterprise.DataImporter.Import()
System.ArgumentException: Cannot be the same as destination
Parameter name: contentLinkID
at EPiServer.DataAccess.ContentSaveDB.Move(Int32 contentLinkID, Int32 destinationLinkID, Boolean archive)
at EPiServer.DataAbstraction.ContentStore.Move(Int32 contentLink, Int32 destinationLinkID, Boolean archive)
at EPiServer.DefaultContentProvider.Move(ContentReference contentReference, ContentReference destinationLink)
at EPiServer.Core.Transfer.ContentTransfer.MoveContent(IContent content, ContentReference parentLink, AccessLevel requiredDestinationAccess)
at EPiServer.Core.Transfer.ContentTransfer.Import(RawContent rawContent, AccessLevel requiredDestinationAccess, Guid& importedPageGuid)
at EPiServer.Core.Transfer.ContentTransfer.Import(ITransferContentData content, AccessLevel requiredDestinationAccess)
at EPiServer.Enterprise.DataImporter.ImportContents[T](XmlTextReader reader, ZipPackage package)
at EPiServer.Enterprise.DataImporter.ImportStream(ZipPackage package, XmlTextReader reader, String partName)
at EPiServer.Enterprise.DataImporter.ImportPartOfPackage(ZipPackage package, String partName)
at EPiServer.Enterprise.DataImporter.ImportRaw(ZipPackage package)
at EPiServer.Enterprise.DataImporter.Import()
I do not get what the problem might be, any help is really appreciated.
P.D.: I already asked the same at EPiServer Dev Forum http://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2016/11/error-during-import-system-argumentexception-cannot-be-the-same-as-destination
I think this is what happens?
Your exported package will be imported below the node you select when importing - not overwrite the selected destination node.
For example, you could export a start page beneath the root page in UAT, and then select Root as the destination in production. On import, the start page would end up below the Root page.
The error occurs when exporting the Root page in your UAT environment, and then trying to export that to the Root page in your production environment.
Essentially you're trying to import the source root page under the destination root page (hence the exception about content ID being the same as the destination ID).
Thanks for the explanation Ted. I did the following and it worked:
In UAT
Export starts: http://screencast.com/t/FgHRnOhuauR with "Export files that the pages link to" unchecked.
Export ends: http://screencast.com/t/aPe0Ntvb9aq
10583 content items were exported into the file.
Then in Production
Import starts: http://screencast.com/t/qqkBsL731P with "Update existing content items with matching ID" checked.
Import in-progress: http://screencast.com/t/reSfMnCV8
One thing I noticed is that at the end it says it only updated a portion of the content items, in fact I did it a couple of times as UAT is being actively edited and got results with 28, 16, 1, or 8 items imported (out of 10500+) I guess that is because those were the only with changes or new items.
I did checked a couple of blocks that I knew were updated and the were matching with the new version after the import.
As this did the work I am marking Ted´s answer as accepted.
I think is kinda confusing the selection of elements in the content tree since I wanted to take everything from root and move it to the root on the other server but it seems that is not how it works.
That error occurs when contentLinkID equals destinationLinkID
The reflected code confirms this
public void Move(int contentLinkID, int destinationLinkID, bool archive)
{
if (contentLinkID == destinationLinkID)
{
throw new ArgumentException("Cannot be the same as destination", "contentLinkID");
}
// ...
Check your episerver log files, they will tell you which contentLinkID that causes the error.
Best guess is that the
application pool account doesn't have sufficient rights on the database or on the file system
application pool cannot write or update the files in app_data
Typically this is where most people give up, instead migrating Episerver using database backup/restore instead. However, if you really want to go full nerd on this I suggest customizing the import, check the article Patrick van Kleef about content migration http://www.patrickvankleef.com/2015/08/18/episerver-content-migration/.
This is an issue Episerver really should fix asap!

SSIS 2012 Project connection manager error

Basically:
I have a project with 4 packages. All on them have different connection managers with the exception of one which is shared between 2 of the packages so I made it a project connection manager.
If I try to build the project, I get the error below.
If I change the project CM to a package CM, it builds fine
So obviously the fact that I have a project CM is the problem.
What can I be missing?
Error 21 System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.SqlServer.Dts.Runtime.ReferenceId.ReferenceMap.Add(String key, String value, Boolean isExternal)
at Microsoft.SqlServer.Dts.Runtime.ReferenceId.RefIdProducer.AddRefIdAttribute(XmlElement element, String objectName, String objectId, ReferenceParserState state)
at Microsoft.SqlServer.Dts.Runtime.ReferenceId.RefIdProducer.GenerateRefId(XmlElement element, ReferenceParserState state)
at Microsoft.SqlServer.Dts.Runtime.ReferenceId.RefIdProducer.ProcessElement(XmlElement element, ReferenceParserState state)
at Microsoft.SqlServer.Dts.Runtime.ReferenceId.RefIdConverter.MapRefIds(IDTSPackage100 package, IDTSInfoEvents100 events, XmlDocument document)
at Microsoft.SqlServer.Dts.Runtime.DTSManagedXmlSerializationHelper.AfterSavePackageToXML(IDTSPackage100 package, IDTSInfoEvents100 events, String& packageXml)
at Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSPackagePersist100.ClonePackageToXML(Object& pvDestination, Boolean vbReturnDOM, IDTSEvents100 pEvents)
at Microsoft.SqlServer.Dts.Runtime.Project.SavePackage(IProjectStorage storage, Package package, String streamName, Boolean preserveVersionGuid)
at Microsoft.SqlServer.Dts.Runtime.Project.SavePackage(Package package, String streamName, Boolean preserveVersionGuid)
at Microsoft.DataTransformationServices.Project.DataTransformationsProjectBuilder.IncrementalBuildThroughObj(IOutputWindow outputWindow)
at Microsoft.DataTransformationServices.Project.DataTransformationsProjectBuilder.BuildIncremental(IOutputWindow outputWindow)
This occurs when you have the same connection manager twice (eg: copied between 2 packages) and you promote one of them to be a project connection.
The first package will show the connection manager of "(project) remoteSystem". The second package will still show "remoteSystem", and the new project level connection will not be shown.
If you delete the package level connection in the second package you will a) resolve the error, and b) the project level connection manager will become visible.
You will then have to go through all components that referenced the connection manager you deleted and re-direct them to the new project level connection.
Moving the CM back to a package and then back to the project resolved it to where I could build.

Reporting Services 2005: Attempt to export to Excel gives "Object reference not set to an instance of an object." error

I have a moderately complex report consisting of a lot of subreports.
One particular one is causing an issue: if you run it standalone, it works fine. If you integrate it as a subreport, it refuses to allow you to export to Excel format (from Preview), with the following error:
An error occurred during local report processing.
An error occurred during rendering of the report.
An error occurred during rendering of the report.
Object reference not set to an instance of an object.
Producing to any other format works fine. Most of my Googling thus far has said "Reinstall Reporting Services", which I really don't want to do (I reinstalled for a previous issue, and it took me a good day or so to get everything happy again - possibly more), especially given it's not a guaranteed fix.
I don't know if it's significant, but the reports do make us of Dundas Charts, which may make it more difficult to parse.
Anyone know a better solution?
Update:
When I try Exporting to Excel on the report server, it gives me this:
Object reference not set to an instance of an object.
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.Exception: Object reference not set to an instance of an object.
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:
[Exception: Object reference not set to an instance of an object.]
[Exception: An error occurred during rendering of the report.]
[Exception: An error occurred during rendering of the report.]
Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream outputStream, String& mimeType, String& fileNameExtension) +520
Microsoft.Reporting.WebForms.ServerReport.InternalRender(Boolean isAbortable, String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +936
Microsoft.Reporting.WebForms.ServerReport.Render(String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +28
Microsoft.Reporting.WebForms.ServerReportControlSource.RenderReport(String format, String deviceInfo, NameValueCollection additionalParams, String& mimeType, String& fileExtension) +85
Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +143
Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +152
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
I ran into the same issue with the below statement. Everything works fine as expected except when exporting to excel.
=iif(ReportItems!textbox343.Value>ReportItems!textbox344.Value or ReportItems!textbox346.Value>ReportItems!textbox347.Value,"Yes","No")
Here is the fix. Added braces and voila voodoo magic it works.
=iif((ReportItems!textbox343.Value>ReportItems!textbox344.Value) or (ReportItems!textbox346.Value>ReportItems!textbox347.Value),"Yes","No")
I believe that the Excel export of a report containing subreports is a known issue in SSRS 2005 and is addressed in 2008. I don't know if the upgrade is an option for you?

Resources