Implemented a virtual path provider to dynamically load some files from a shared project in a new web application. Everything works fine in dev/deployed and local IIS. When deploying to production we are encountering "Failed to start monitoring file changes" error when trying to find a 'virtual file'. GetCacheDependency is overridden in our VirtualPathProvider but when I remote debug the function is never hit. Any Ideas?
EDIT:
public override System.Web.Caching.CacheDependency GetCacheDependency(string virtualPath, System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart)
{
if (CheckVirtual(virtualPath))
{
string realName = CustomVirtualPathProvider.CleansePath(virtualPath);
return new System.Web.Caching.CacheDependency(baseDirectory + realName);
}
return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
}
I register the VPP in the global asax. It only fails in production which leads me to believe that its a iis settings issue.
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:
Related
I am trying to deploy an app that I used Crystal Reports in. I want to say that it works on local host as I am using IIS Express and in staging I am using IIS. This is the main difference that I can think of but just to be sure I want to write out the entire process that have done.
Build Report in Visual Studio
Create ODBC Connection on local host
Run Report in localhost - it works
publish MVC app
add ODBC connection with same name on server
copy report to correct location on IIS server
run app and report app works report doesn't.
The log that I am getting is:
FATAL 2018-08-28 03:22:30,923 37280ms Log Service GenerateReport - Exception during StringFormat: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. Generate Reports at: 8/28/2018 3:22:30 AM, Exception: CrystalDecisions.CrystalReports.Engine.InternalException: Failed to open the connection.
QuoteReport 5092_4216_{0FAD9DBD-DCD7-4158-816D-56895A79B362}.rpt
Details: [Database Vendor Code: 4060 ] ---> System.Runtime.InteropServices.COMException: Failed to open the connection.
QuoteReport 5092_4216_{0FAD9DBD-DCD7-4158-816D-56895A79B362}.rpt
Details: [Database Vendor Code: 4060 ]
at CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.Export(ExportOptions pExportOptions, RequestContext pRequestContext)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
--- End of inner exception stack trace ---
at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)
at CrystalDecisions.ReportSource.EromReportSourceBase.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.FormatEngine.ExportToStream(ExportRequestContext reqContext)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportOptions options)
at CrystalDecisions.CrystalReports.Engine.ReportDocument.ExportToStream(ExportFormatType formatType)
at QuickQuote.Controllers.ReportsController.GenerateReport(Int32 reportId, String json) in C:\Users\James\Source\Repos\QuickQuote3\QuickQuote\Controllers\ReportsController.cs:line 84{}
Can someone please tell me what my issue is? I have google this error and I don't understand what my issue is.
try
{
var stream = _reportBuilder.BuildReport(dataSet, report, filePath, parameters);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/pdf", $"Quote{report.Name}-{DateTime.Now}.pdf");
}
catch (Exception e)
{
_loggingService.FatalFormat($"Generate Reports at: {DateTime.Now}, Exception: {e}");
throw;
}
Inside reportBuilder.BuildReport is where it is breaking. I'm sure that it is this line:
var stream = reportDocument.ExportToStream(ExportFormatType.PortableDocFormat);
BuildReport method:
public Stream BuildReport(DataSet dataSet, Report report, string path, string parameters)
{
var reportDocument = new ReportDocument();
reportDocument.Load(path);
reportDocument.SetDataSource(dataSet);
AddParametersToReport(ref reportDocument, report, parameters);
return reportDocument.ExportToStream(ExportFormatType.PortableDocFormat);
}
The exception message is Failed to open the connection.
Verify if System Data Sources are set up correctly in ODBC Data Source Administrator (for both 32-bit and 64-bit).
You may get Database logon failed error, as credentials specified in .rpt file might be invalid for the database. The solution is to provide database credentials in code:
public Stream BuildReport(DataSet dataSet, Report report, string path, string parameters)
{
try
{
var reportDocument = new ReportDocument();
reportDocument.Load(path);
reportDocument.SetDataSource(dataSet);
AddParametersToReport(ref reportDocument, report, parameters);
// Set database credentials
reportDocument.SetDatabaseLogon("dbUsername", "dbPassword");
return ReportDocument.ExportToStream(ExportFormatType.PortableDocFormat);
}
catch(Exception ex)
{
_loggingService.FatalFormat($"Exception: {ex}");
throw;
}
}
Just some background: it was working code in Production since 2013. Recently added DB password encrypt/decrypt logic in code - compiled code using VS2010 - it's working fine in test but not in Production.
I am assuming it has something to do with configuration xml , mapping or some mismatch of NHibernate dll. Not sure if build/output folders need some thing?
Error in Production:
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
NHibernate MappingException: Could not compile the mapping document: (XmlDocument) ---> System.InvalidCastException: [A]NHibernate.Cfg.MappingSchema.HbmMapping cannot be cast to [B]NHibernate.Cfg.MappingSchema.HbmMapping. Type A originates from 'NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\drcwm\bb04bdb4\da32eda4\assembly\dl3\bb71f3c5\00f7c13c_ef33d101\NHibernate.dll'. Type B originates from 'NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' in the context 'LoadFrom' at location 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\drcwm\bb04bdb4\da32eda4\assembly\dl3\44ab434f\00f7c13c_ef33d101\NHibernate.dll'.
at NHibernate.Cfg.XmlHbmBinding.Binder.Deserialize[T](XmlNode node)
at NHibernate.Cfg.XmlHbmBinding.MappingRootBinder.Bind(XmlNode node)
at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)
--- End of inner exception stack trace ---
at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)
at NHibernate.Cfg.Configuration.AddInputStream(Stream xmlInputStream, String name)
at NHibernate.Cfg.Configuration.AddDocument(XmlDocument doc, String name)
at FluentNHibernate.PersistenceModel.Configure(Configuration cfg)
at FluentNHibernate.Cfg.FluentMappingsContainer.Apply(Configuration cfg)
at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration cfg)
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration()
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
at DB.FIOS_SOUTH.DataBase.get_SessionFactory()
NLog.LoggerImpl.Write Error "System.NullReferenceException: Object reference not set to an instance of an object.
at DB.Base.DataBase.get_Session()
at DB.Base.DataBase.Query[T]()
at RemoteService.BaseListService.FilteredQuery[T](BaseParameter parameter, DataBase db, Boolean applyPagination, Boolean applySortOrder)
at RemoteService.JobsListService.GetJobsWithChildrenCount[T](JobParameter parameter)
Code throwing exception is below:
if (_ISessionFactory == null)
{
try
{
_ISessionFactory = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005
.ConnectionString(ConnectionString).IsolationLevel(IsolationLevel.ReadUncommitted)
.Cache(c => c.ProviderClass<HashtableCacheProvider>())
)
.Mappings(m =>
{
m.HbmMappings
.AddFromAssemblyOf<FIOS_NORTH_QUEUES.DataBase>();
m.FluentMappings
.AddFromNamespaceOf<FIOS_NORTH_QUEUES.Map.QueueWFADOItemMap>();
})
.ExposeConfiguration(ModifyConfiguration)
.BuildSessionFactory();
}
catch (Exception ex)
{
logger.Error(ex);
}
}
your production process has already loaded NHibernate from an old (shadow-)cache location then the new dlls are loaded from a new location and try to load their dependencies next to them, but since the process already loaded the assemblies from elsewhere it has a conflict.
You have to try unloading/restarting the AppDomain by restarting the server process, asp.net process, iis, whatever. The error is not related to the code at all.
I am trying to clone a git repository from the local file system:
using System;
using LibGit2Sharp;
class Program
{
static void Main()
{
var sourceUrl = #"file:///c:/work/libgit2sharp";
using (Repository.Clone(sourceUrl, "targetDir", bare: true))
{
Console.WriteLine("repository successfully cloned");
}
}
}
and I get an exception:
Unhandled Exception: LibGit2Sharp.LibGit2SharpException: An error was raised by libgit2. Category = Odb (Error).
Failed to find the memory window file to deregister
at LibGit2Sharp.Core.Ensure.Success(Int32 result, Boolean allowPositiveResult) in c:\work\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 85
at LibGit2Sharp.Core.Proxy.git_clone_bare(String url, String workdir, git_transfer_progress_callback transfer_cb) in c:\work\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 219
at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, Boolean bare, Boolean checkout, TransferProgressHandler onTransferProgress, CheckoutProgressHandler onCheckoutProgress) in c:\work\libgit2sharp\LibGit2Sharp\Repository.cs:line 431
at Program.Main() in c:\work\ConsoleApplication1\Program.cs:line 10
I've also tried the following source url:
var sourceUrl = #"c:\work\libgit2sharp\.git\";
and got another exception:
Unhandled Exception: LibGit2Sharp.LibGit2SharpException: An error was raised by libgit2. Category = Config (Error).
Failed to parse config file: Unexpected end of file while parsing multine var (in c:/work/ConsoleApplication1/bin/Debug/targetDir/config:23, column 0)
at LibGit2Sharp.Core.Ensure.Success(Int32 result, Boolean allowPositiveResult) in c:\work\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 85
at LibGit2Sharp.Core.Proxy.git_clone_bare(String url, String workdir, git_transfer_progress_callback transfer_cb) in c:\work\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 219
at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, Boolean bare, Boolean checkout, TransferProgressHandler onTransferProgress, CheckoutProgressHandler onCheckoutProgress) in c:\work\libgit2sharp\LibGit2Sharp\Repository.cs:line 431
at Program.Main() in c:\work\ConsoleApplication1\Program.cs:line 12
targetDir is never created.
If on the other hand I use HTTP transport, the Repository.Clone method works fine:
var sourceUrl = "https://github.com/libgit2/libgit2sharp";
So my question is if I am doing something wrong or if this is unsupported feature or a bug in the native git2.dll?
So my question is if I am doing something wrong or if this is unsupported feature or a bug in the native git2.dll?
A bit a both, actually.
The first exception is clearly a bug. This should not happen and will be troubleshot.
The second one requires a deeper analysis. Would you be so kind as to open a issue in the LibGit2Sharp project?
Good news are that a pull request from BenStraub was recently merged. This pull request implements the local fetch transport which should pretty solve the issue.
LibGit2Sharp will be updated in the following days with a new a new version of libgit2 binaries which should allow you perform a local clone/fetch. I'll update this answer as soon as it's been done.
Update
This test shows how do to a Clone and a Push over against a local repository.
Getting this exception The file size exceeds the limit allowed and cannot be saved when writing to event viewer using EventLog
Code used:
string cs = "LoggingService";
EventLog elog = new EventLog();
if (!EventLog.SourceExists(cs))
{
EventLog.CreateEventSource(cs, cs);
}
elog.Source = cs;
elog.EnableRaisingEvents = true;
elog.WriteEntry(message);
Stack trace:
System.ComponentModel.Win32Exception (0x80004005): The file size exceeds the limit allowed and cannot be saved
at System.Diagnostics.EventLogInternal.get_OldestEntryNumber()
at System.Diagnostics.EventLogInternal.StartRaisingEvents(String currentMachineName, String currentLogName)
at System.Diagnostics.EventLogInternal.set_EnableRaisingEvents(Boolean value)
Things tried:
http://support.microsoft.com/kb/328380#top
When I put this statement elog.Clear() before elog.EnableRaisingEvents = true;
I am getting different exception
System.ComponentModel.Win32Exception (0x80004005): Access is denied
at System.Diagnostics.EventLogInternal.Clear()
The above code is executed by a web service which runs under LocalSystem which has full permission on the computer.
OS: windows server 2008R2 and .NET 4.0
There is a method EventLog.ModifyOverflowPolicy that modifies log policy.
I believe EventLog.ModifyOverflowPolicy(OverflowAction.OverwriteAsNeeded,0) could be helpful.
Event Viewer - Properties - Maximum log size was 1028. I bumped it and it started working fine.
But the same code was working from another window service before I made the above the change.
which make me think what could have happened
The message I was trying to log was just a line (less then 255 characters)
I'm trying to write something that (amongst other things) adds a user to an AD group - using VS2010, .Net4 and the library facilities in System.DirectoryServices.AccountManagement.
I've gotten a user and group by code like the sample below, and this works for other operations like enabling or disabling accounts.
group = System.DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(_UserContext, Name);
user = System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(_UserContext, Name);
Now, trying to add the user to the group like:
group.Members.Add(user);
I get an error with a stack trace beginning like the one listed below with a COM interop error 0x80005000 (unknown). This also happens with other users and on 32 and 64 bit builds. Searching this on the web comes up with a few forum questions, but I can't find any answers. In theory, this should work - this codeproject sample is doing much the same thing.
Has anyone seen this error or have any idea what might have caused it?
Stack trace top:
Unhandled Exception: System.DirectoryServices.AccountManagement.PrincipalOperati
onException: Unknown error (0x80005000) ---> System.Runtime.InteropServices.COME
xception: Unknown error (0x80005000)
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne
)
at System.DirectoryServices.DirectorySearcher.FindOne()
at System.DirectoryServices.AccountManagement.ADStoreCtx.IsMemberOfInStore(Gr
oupPrincipal g, Principal p)
--- End of inner exception stack trace ---
at System.DirectoryServices.AccountManagement.ADStoreCtx.IsMemberOfInStore(Gr
oupPrincipal g, Principal p)
at System.DirectoryServices.AccountManagement.PrincipalCollection.ContainsNat
iveTest(Principal principal)
at System.DirectoryServices.AccountManagement.PrincipalCollection.Contains(Pr
incipal principal)
at System.DirectoryServices.AccountManagement.PrincipalCollection.Add(Princip
al principal)
at System.DirectoryServices.AccountManagement.PrincipalCollection.Add(UserPri
ncipal user)
I also ran into the same issue with a (GroupPrincipal instance).Members.Add(UserPrincipal instance).
The workaround (in IronPython) is rather simple thanks to the GetUnderlyingObject method.
de = group.GetUnderlyingObject
# Group member DNs are kept in 'member' attribute in LDAP
de.Properties['member'].Add(user.DistinguishedName)
de.CommitChanges() # Save your work
Just ran into this and noticed that the code project sample was explicitly using the domain's name when creating the context (instead of using null). I changed my code to explicitly specify the domain name, and now it's working fine - I can group.Members.Add(user) without issue.