'License expired' error when dynamically generating Excel docs in ASP.NET - asp.net

Anyone familiar with error below? When I run my webapp to generate a dynamic excel doc from my local machine it works fine but when the same piece of code is invoked on the server I get the below error. It seems like it's a permissions issues since it works on my machine but not the server but I don't know where to start in order to pinpoint the problem. Any guidance/help is greatly appreciated!
Server Error in '/' Application.
--------------------------------------------------------------------------------
This command is unavailable because the license to use this application has expired.
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.Runtime.InteropServices.COMException: This command is unavailable because the license to use this application has expired.
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:
[COMException (0x800a03ec): This command is unavailable because the license to use this application has expired.]
Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template) +0
PaymentsReport.Page_Load(Object sender, EventArgs e) +70
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
Office/Excel is installed on the server and I can open/save excel docs on the server. Could it be the version of excel on the server vs. my local machine? If so how can I make sure I have the latest on the server?

Apart from being installed, you need to make sure the application is activated on the server:
http://support.microsoft.com/kb/294973
Has details on how to do this.

Using Office Interop requires that the Office components you're using actually be installed on the server.

I'm gonna take a WAG and say that you just can't slap any old copy of Office on a server and let multiple users access it via your website. You need to look at the licensing restrictions for using MS office in a server environment.

Do you have a licensed, activated copy of Excel on the server? It probably works on your local machine because you have Office/Excel installed locally.

Related

IIS appwhen adding a binding. servername.domain.com/app works, but appname.domain.com/app doesn't

I have a server whose sole purpose is to host a prebuilt IIS app from a vendor.
The server has been built, IIS is working, and with everything installed, the app is accessible from http://servername.domain.com/app
I want to add an alternate URL, to be http://appname.domain.com/app, for ease of use and cleanliness.
I added the binding on both ports 80 and 443 with our site cert, using all unassigned IPs and none of the boxes ticked.
Despite changing nothing but the bindings, I'm getting the following error attempting to use the newly bound URL:
Value cannot be null.
Parameter name: source
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.ArgumentNullException: Value cannot be null.
Parameter name: source
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:
[ArgumentNullException: Value cannot be null.
Parameter name: source]
System.Linq.Enumerable.Where(IEnumerable`1 source, Func`2 predicate) +6466184
Xtraction.Web.Auth.Authenticate.HasSingleActiveProvider() +185
Xtraction.Web.Auth.Authenticate.Page_Load(Object sender, EventArgs e) +115
System.Web.UI.Control.OnLoad(EventArgs e) +106
Xtraction.Web.PageBase.OnLoad(EventArgs e) +17
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785
Based on the error information you provided, the reason I retrieved is that your application pool is not set up to use a service account, which prevents you from logging into Xtraction.
You need to set the application pool to use the Windows service account:
Go to IIS Manager > Servers > Application Pools > Xtraction
Click the Advanced Settings link in the right pane
Go to the Identity section, if it's set to Network Service, then click the ellipsis on the right
Change to "Custom Account" and enter your service account - this must have dbowner (or at least db_datareader and db_datawriter)
permissions on the Xtraction database
Click OK and restart the application pool (or execute iisreset). You should now be able to log in to Xtraction
For more information, you can refer to this link.

ASP.NET - Accessing Active Directory from code behind page

I have made a web application, which reads/writes from/to Active Directory. In my web.config file there is
<identity impersonate="true"/>
and
<authentication mode="Windows"/>
When I display
System.Web.HttpContext.Current.User.Identity.Name
in some label, it shows mydomain\myusername, so I think impersonation works.
Now to the question. When I access the application on the server, where the IIS web server is running, everything works great. But when I access the web application from a remote PC, I get an exception (the label still shows "mydomain\myusername").
I have traced the problem down. In the code behind when I call
Forest currentForest = Forest.GetCurrentForest();
the variable currentForest knows its currentForest.Name, currentForest.RootDomain or currentForest.ForestMode, but any call to currentForest.Domains, currentForest.Sites or currentForest.GlobalCatalogs results in
System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException.
Now I'm lost and don't know what to debug further. The account I'm using is member of Enterprise Admins (multi-domain forest). I have tried it on two different servers with different IIS versions (IIS 7.5 and IIS 6.0) with no luck.
And the thrown exception isn't of much help:
Exception Details: System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred.
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:
DirectoryServicesCOMException (0x80072020): An operations error occurred.
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +557
System.DirectoryServices.DirectoryEntry.Bind() +44
System.DirectoryServices.DirectoryEntry.get_AdsObject() +42
System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) +98
System.DirectoryServices.ActiveDirectory.ADSearcher.FindAll() +46
System.DirectoryServices.ActiveDirectory.Forest.GetDomains() +543
[ActiveDirectoryOperationException: An operations error occurred.]
System.DirectoryServices.ActiveDirectory.Forest.GetDomains() +512484
System.DirectoryServices.ActiveDirectory.Forest.get_Domains() +44
myWebApp.ASPpage.Button_Click(Object sender, EventArgs e) in C:\Documents and Settings\myUser\documents\visual studio\Projects\MyWebApp\MyWebApp\ASPPage.aspx.cs:158
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
EDIT: If it is not obvious, I want to use currentForest.Domains to search the whole forest (all domains) for a user given by UPN name.
I found the answer to my question in one of "Related questions" on this page. The answer was in this topic: Why does DirectoryServicesCOMException occur querying Active Directory from a machine other than the web server?
I found, that it was exactly my case. After reading the suggested Microsoft article, I learned, that impersonating works only for local resources on the IIS server. To access network resources (SQL, Active Directory), I have to set "Trust this computer for delegation" in the computer object in Active Directory.
It was because the IIS always authenticate therefore System.Web.HttpContext.Current.User.Identity.Name showsmydomain\myusername; to verify that the impersonation works you could use:
System.Security.Principal.WindowsIdentity.GetCurrent().Name, also the System.Security.Principal.WindowsIdentity.GetCurrent(true) returns null when it is not impersonating.

WF 4.0 can't get to resume workflow on the staging/production environment

I have developed various registeration workflows using WF4.0. Each work flow has various bookmarks. I am using the registeration wf for an asp.net application.
I tested the asp.net application locally and it is working fine( Starting WF, Persisting to db and resuming bookmarks). When I try to test it on the staging server, everything goes messy. I can no longer resume wfs and I get an error message :
System.Runtime.DurableInstancing.InstancePersistenceCommandException
was unhandled by user code Message=The execution of the
InstancePersistenceCommand named
{urn:schemas-microsoft-com:System.Activities.Persistence/command}LoadWorkflow
was interrupted by an error. Source=System.Runtime.DurableInstancing
StackTrace:
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.Runtime.DurableInstancing.InstancePersistenceContext.OuterExecute(InstanceHandle
initialInstanceHandle, InstancePersistenceCommand command, Transaction
transaction, TimeSpan timeout)
at System.Runtime.DurableInstancing.InstanceStore.Execute(InstanceHandle
handle, InstancePersistenceCommand command, TimeSpan timeout)
at System.Activities.WorkflowApplication.PersistenceManager.Load(TimeSpan
timeout)
at System.Activities.WorkflowApplication.LoadCore(TimeSpan timeout, Boolean loadAny)
at System.Activities.WorkflowApplication.Load(Guid instanceId, TimeSpan timeout)
at System.Activities.WorkflowApplication.Load(Guid instanceId)
at CEO_StartUpCEORegisterationTest.LoadInstance(Guid wfInstanceId) in c:\Users\Kunoichi\Documents\Visual Studio
2010\Projects\CMERegistrationSystem\RegistrationPortal\CEO\StartUpCEORegisterationTest.aspx.cs:line
64
at CEO_StartUpCEORegisterationTest.Page_Load(Object sender, EventArgs e) in c:\Users\Kunoichi\Documents\Visual Studio
2010\Projects\CMERegistrationSystem\RegistrationPortal\CEO\StartUpCEORegisterationTest.aspx.cs:line
44
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,
EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: System.Data.SqlClient.SqlException
Message=Index 'NCIX_KeysTable_SurrogateInstanceId' on table 'KeysTable' (specified in the FROM clause) does not exist.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=211
Number=308
Procedure=LoadInstance
Server=
State=1
StackTrace:
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.Activities.DurableInstancing.SqlWorkflowInstanceStoreAsyncResult.SqlCommandAsyncResultCallback(IAsyncResult
result)
I know that this is quite verbose. But I have been banging my head against the wall for more than a week. I did search and all I came to know was to work on ms dtc. I enabled it on the staging server , I installed application server on the staging server and I am still getting the same error. I would appreciate if anyone could help with the problem. Thanks in advance :)
Who created the persistence store being used on the staging server? What schema was used to create it? Look for differences between the scripts used locally and in production.

Web App works on localhost but fails on remote connection

We have a new ASP.NET web application we are deploying that uses a separate DLL which we also built which in turn interrogates the Active Directory for simple user and group membership information. The server is Windows Server 2003.
The application works fine if I RDP to the server and browse it under localhost.
The application throws the following error when I browse to it from a separate PC. It also throws the same error if I browse to it from the RDP session on the server, but browse it under the server name.
Is this a code-access security issue? Other ideas?
Exception Details: System.Runtime.InteropServices.COMException: An operations error occurred.
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:
[COMException (0x80072020): An operations error occurred.
]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +420085
System.DirectoryServices.DirectoryEntry.Bind() +36
System.DirectoryServices.DirectoryEntry.get_Name() +32
USM.UsmAD.get_DomainName() in C:\DevWork\Repo_CP\UnifiedSecurity\BRANCHES\LoginVsGUID\Applications\Active Directory Search\USMAD\USMAD\UsmAD.cs:60
USM.UsmAD.Get_UserGroupNames(String username) in C:\DevWork\Repo_CP\UnifiedSecurity\BRANCHES\LoginVsGUID\Applications\Active Directory Search\USMAD\USMAD\UsmAD.cs:190
AdminWeb.CheckAccessDAL.GetGroupNames() in C:\DevWork\Repo_CP\UnifiedSecurity\BRANCHES\LoginVsGUID\Applications\AdminWeb\USMDAL\CheckAccessDAL.cs:28
AdminWeb.CheckAccessDAL.SetMenuAccess(Menu mnuUSMAdmin) in C:\DevWork\Repo_CP\UnifiedSecurity\BRANCHES\LoginVsGUID\Applications\AdminWeb\USMDAL\CheckAccessDAL.cs:89
AdminWeb.SiteMaster.TrimMainMenus() in C:\DevWork\Repo_CP\UnifiedSecurity\BRANCHES\LoginVsGUID\Applications\AdminWeb\AdminWeb\Site.Master.cs:50
AdminWeb.SiteMaster.Page_Load(Object sender, EventArgs e) in C:\DevWork\Repo_CP\UnifiedSecurity\BRANCHES\LoginVsGUID\Applications\AdminWeb\AdminWeb\Site.Master.cs:17
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Control.LoadRecursive() +146
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
sounds like a perms issue on the dll
try allowing IUSR access to this file....
You will probably need to run your app pool under an domain level identity that has permission to access the resources it needs to talk to Active Directory.
Specify an Identity for an Application Pool (IIS 7)
Configuring Application Pool Identity with IIS 6.0 (IIS 6.0)
Here is an article if you need to do this at runtime:
How To: Use Impersonation and Delegation in ASP.NET 2.0
I also encourage you to implement an UnhandledException handler to log these run-time errors.

IIS7 giving Object reference not set to an instance of an object error

I have an IIS7 application that is using the .net 4.0 framework. The application pool has the rights (read/write/execute) on the folder of the application and has (select/read/connect) rights to the Database. IIS7 accept the aspx files and everything seems fine int eh settings however i am getting a 404 error when I am calling ti from outside of the server.
When I go in the server and call the http://localhost link, i get this error
Server Error in '/Phonebook/PhoneBook' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhanded 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.NullReferenceException: 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:
[NullReferenceException: Object reference not set to an instance of an object.]
PhoneBookApplication.DBUtils.Execute(SqlCommand command) +399
PhoneBookApplication._Default.FillddlSearch() +156
PhoneBookApplication._Default.Page_Load(Object sender, EventArgs e) +54
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
System.Web.UI.Control.LoadRecursive() +70
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3047
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
If I call a default-defaut.html file, it works, but not if I call the default-defaut.aspx. But in the daufault pages settings, both aspx and html are there.
Also, it seems to have something to do with the sql server, but I do not understand where to look to debug that
I have no idea what is doing this. Can someone help?
The method DBUtils.Execute seems to have an error. What do do you have on the page_load or any event before the page_load ?
The error is telling you exactly where the problem is:
Your line 399 of the DBUtils class has a bug:
PhoneBookApplication.DBUtils.Execute(SqlCommand command) +399
IIS is not the problem. If you are getting a 404 error is because you are not going to the correct URL.

Resources