Recently I have been trying to port a classic ASP application to ASP.Net. The major thing to do was to keep using CAPICOM for encryption. The reason was that the data we encrypt goes to a 3rd party vendor who decrypts them using CAPICOM and they were not going to change their side of the program.
Two specific problems that I encountered whenever deploying my application to servers.
a.) Retrieving the COM class factory for component with CLSID {94AFFFCC-6C05-4814-B123-A941105AA77F} failed due to the following error: 80040154
This I could resolve by registering the CAPICOM dll on the server (regsvr32). I was assuming that this would not be necessary given that I have a .Net wrapper around the CAPICOM dll (using tlbimp. MSDN).
b.) Keyset does not exist
Searching on Bing/Google led me to several sites saying it's permission issue on the Machine Keys folder. I tried setting permission for all users I could think of: ASPNet, IUSR, IWAM, Service Account. But this did not help. Then I imported the certificate from the old machine where classic ASP application is running and voila! the encryption algorithm started working. I removed all permission settings for the ASP.Net users mentioned before and it still worked.
I am not sure why this is!
Thursday, September 29, 2011
Wednesday, September 28, 2011
Surface Area Configuration: Computer localhost does not exist on the network, or the computer cannot be configured remotely
I was trying to connect to a local instance of SQL Server from a Dev app server. The application would fail saying
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 0 - No process is on the other end of the pipe.)So I brought up the SQL Server Surface Area Configuration tool (Programs> SQL Server 2005> Configuration Tools >SQL Server Surface Area Configuration) and clicked on Surface Area Configuration for Services and Connections. And this will throw an error:
TITLE: Surface Area Configuration ------------------------------ Computer localhost does not exist on the network, or the computer cannot be configured remotely. Verify that the remote computer has the required Windows Management Instrumentation components and then try again. (SQLSAC) ------------------------------ ADDITIONAL INFORMATION: An exception occurred in SMO while trying to manage a service. (Microsoft.SqlServer.Smo) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.3042.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.InnerWmiException&LinkId=20476 ------------------------------ Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476 ------------------------------ Invalid class (System.Management) ------------------------------ BUTTONS: OK ------------------------------While searching for a solution I came across this blog http://blogs.msdn.com/b/echarran/archive/2006/01/03/509061.aspx. Ran the command as mentioned there and I was able to bring up the Surface Area Configuration tool.
Thursday, September 8, 2011
Interdev connection failed: Method not allowed(Error code = 80070005)
I was recently re-writing a classic ASP web application into .Net. So I was trying to create a web project in Visual Studio InterDev when I got this error.
My environment: XP SP2, IIS 6.
Resolution: I did not have Microsoft FrontPage extensions installed.
To check
a.) go to Control Panel > Add Remove Programs > Add Remove Windows Component
b.) Select Internet Information Services (IIS)
c.) Click Details and ensure FrontPage 2000 Server Extensions option is checked. If not, check it and click OK.
That did it for me and may help you too.
Tuesday, July 19, 2011
Case Insensitive Replace() function
For some reason .Net framework does not have the case insensitive replace method in the String class. I found it can very easily be implemented for String class using Extension Method feature of .Net.
Here's the method:
And calling this method seems trivial:
That's it.
Here's the method:
public static string Replace(this string originalString, string oldValue, string newValue, StringComparison comparisonType)
{
int startIndex = 0;
while (true)
{
startIndex = originalString.IndexOf(oldValue, startIndex, comparisonType);
if (startIndex == -1)
break;
originalString = originalString.Substring(0, startIndex) + newValue + originalString.Substring(startIndex + oldValue.Length);
startIndex += newValue.Length;
}
return originalString;
}
And calling this method seems trivial:
originalString = originalString.Replace(@"ABCD", "abcd", StringComparison.InvariantCultureIgnoreCase);
That's it.
Monday, July 18, 2011
CSS Refresh issue in Firefox
While developing a website in ASP.Net I noticed that my CSS file was not immediately refreshed in Firefox and until I noticed; it caused me to think that the CSS I was trying is not correct. Ctrl+F5; Ctrl+R etc does not work.
I found modifying the entry in config did the trick for me:
But I believe it should not be that you have to modify config file for the new CSS to load into the browser. But for now this works.
I found modifying the entry in config did the trick for me:
network.http.use-cache = false
But I believe it should not be that you have to modify config file for the new CSS to load into the browser. But for now this works.
Monday, June 27, 2011
Metadata contains a reference that cannot be resolved
While adding a service reference to my project, I started getting an error
I had added other service references without issues and was having a bit of trouble finding out what the problem is. The suggestions given in browser (if you try to browse from IIS Manager) were about setting httpGetEnabled to true. So I checked in the web.config of my service site and found it was set to true.
When I opened the WCF config editor (my preferred way of modifying service site web config) I saw that the "Behavior Configuration" value for the the service was not set. Selecting the right behavior from the drop down was all that I needed to do.
The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved: 'http://localhost/IDM.ProVue.DAWS/WS_Results.svc'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost/IDM.ProVue.DAWS/WS_Results.svc. The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
I had added other service references without issues and was having a bit of trouble finding out what the problem is. The suggestions given in browser (if you try to browse from IIS Manager) were about setting httpGetEnabled to true. So I checked in the web.config of my service site and found it was set to true.
When I opened the WCF config editor (my preferred way of modifying service site web config) I saw that the "Behavior Configuration" value for the the service was not set. Selecting the right behavior from the drop down was all that I needed to do.
Wednesday, June 22, 2011
Dundas Chart and AJAX Calendar control overlap issue
The layout of my webpage (an ASP.Net content page) was:
Date PickerDundas Chart
The page displayed fine but if you click on the calendar image button of the calendar control, the view that pops up is rendered behind the chart control. This was happening in Chrome, FF & IE.
I found a discussion on Dundas support forum: http://support2.dundas.com/forum/tm.aspx?m=6100&mpage=1&key=&
Even after overriding the style class (.ajax__calendar or ajax__calendar_container) in my .css file I could not get the calendar to show up on top of the dundas chart.
Then I found a conversation on SO: http://stackoverflow.com/questions/302244/why-is-my-calendarextender-getting-overlapped-when-rendered
and the thing that worked for me was putting the style in the .ascx file
<*style type="text/css">.ajax__calendar_container { z-index : 1000 ; }<*/style>I am still not sure why this happens, but that's what worked for now. If I get a satisfactory explanation I'll post here.
Thursday, February 24, 2011
System.UnauthorizedAccessException: Access to the path is denied
During my recent deployment to a QA box, one of the functionalities "Upload File" of the web app would not work.
Here is what I had done. During development I observed that the file upload would work when I was running the app in Debug mode, from within Visual Studio. When I tried running the app from virtual directory (as in http://localhost/MyApp/Upload.aspx) the file upload would fail with "Logon failure: unknown user name or bad password", about which I blogged a while ago. And hence I added the code to impersonate the current logged in user. And it worked fine.
However, the same impersonation code would not work when the app was deployed on the server. Another thing I should point out is, the file copy is happening on a server different from the app server. When I commented out the impersonation code, it started working. I am still not sure why it so happened.
Windows authentication for an NT group
Recently I implemented authentication system where the logged in user has to be part of the company domain (handled by IIS) and should belong to an app specific NT group. The code used was simple
It worked fine on development machine, but would redirect me to access denied page on the QA server.
After logging the current context user in app (during security check) I found the web app was running under the admin account. And the admin account was not part of my app NT group. The reason this was happening was because Windows explorer cached the admin account credentials, that I use for copying the published files on the server.
To clear the cache, I had to run the following from command prompt:
foreach (System.Security.Principal.IdentityReference group in currentContext.Request.LogonUserIdentity.Groups)
{
groupName = group.Translate(typeof(System.Security.Principal.NTAccount)).ToString();
if (groupName.Equals(userGroup, StringComparison.InvariantCultureIgnoreCase))
{
userIsInGroup = true;
break;
}
}
It worked fine on development machine, but would redirect me to access denied page on the QA server.
After logging the current context user in app (during security check) I found the web app was running under the admin account. And the admin account was not part of my app NT group. The reason this was happening was because Windows explorer cached the admin account credentials, that I use for copying the published files on the server.
To clear the cache, I had to run the following from command prompt:
rundll32.exe keymgr.dll, KRShowKeyMgrThis brings up a UI that has all the server names for which Windows explorer has cached the credentials. Select the server and click on "Remove" and that should do the trick.
Thursday, February 3, 2011
Multiple group headers in BOXI Crystal reports
Yesterday I just found an interesting issue with Crystal Reports XI.
We had a report where in we had to place 5 group headers. After applying all the options what we observed was that the group headers would appear multiple times whenever the group values changed. Searched a lot for answers but to no avail. We're working on it and I'll post the solution as well once we get it.
Workaround::
The solution to this kind of issue is that we should put the different grouping fields in different group header and suppress those groups. Whatever values are to be shown on the report needs to go in the last group header whose corresponding Group Footer has the New Page After property set. This resolves the issue.
We had a report where in we had to place 5 group headers. After applying all the options what we observed was that the group headers would appear multiple times whenever the group values changed. Searched a lot for answers but to no avail. We're working on it and I'll post the solution as well once we get it.
Workaround::
The solution to this kind of issue is that we should put the different grouping fields in different group header and suppress those groups. Whatever values are to be shown on the report needs to go in the last group header whose corresponding Group Footer has the New Page After property set. This resolves the issue.
Wednesday, December 1, 2010
SSRS Split method to get the last element of the split array
One of the report columns had the entire folder path, but all I wanted to show was the innermost folder name and exclude all the parent folders.
For example, from the path C:\Dropboxes\DeviceType\LogFiles\DeviceName\Tuesday\ the report should just show "Tuesday".
Split function is the first thing that comes to mind and that's what I saw in SSRS list of expression methods and used.
The second split is to get the count of total elements as I need to find the last element of the split array, and the folder path depth is not static.
For example, from the path C:\Dropboxes\DeviceType\LogFiles\DeviceName\Tuesday\ the report should just show "Tuesday".
Split function is the first thing that comes to mind and that's what I saw in SSRS list of expression methods and used.
=Split(Fields!FolderPath.Value.ToString(),"\",-1)(Split(Fields!FolderPath.Value.ToString(),"\",-1).GetUpperBound(0)-1)
The second split is to get the count of total elements as I need to find the last element of the split array, and the folder path depth is not static.
Tuesday, November 30, 2010
ASP.Net authorization and Custom Role Provider
In the application I was developing, I had custom role provider implemented for laying out the menu items depending on the privilege each web user has. It had been a while since this part of the application was done. Towards the end of development a requirement came up to redirect users to a "Request Access" page if they do not have access to the application.
I thought of implementing this the easiest way by setting values for in web.config. "AppAccessGroup" was a group I created on my local machine with my NT-id as a member of the group.
But it didn't work right off the bat, and that was confusing. I also had Anonymous access turned off in IIS, so the browser was prompting me for NT credentials. While trying to figure this out, I had a surprising find here: http://blogs.msdn.com/b/dougste/archive/2006/07/27/680031.aspx
But that fix didn't work too.
After a while it stuck me that it may be the custom role provider and I commented that out, to test. And voila!, it worked.
I hadn't seen anybody mention this anywhere, but sure somebody must have had this issue and figured it before.
I thought of implementing this the easiest way by setting values for
< authorization>
< allow roles="AppAccessGroup"/>
< deny users="*">
But it didn't work right off the bat, and that was confusing. I also had Anonymous access turned off in IIS, so the browser was prompting me for NT credentials. While trying to figure this out, I had a surprising find here: http://blogs.msdn.com/b/dougste/archive/2006/07/27/680031.aspx
But that fix didn't work too.
After a while it stuck me that it may be the custom role provider and I commented that out, to test. And voila!, it worked.
I hadn't seen anybody mention this anywhere, but sure somebody must have had this issue and figured it before.
Tuesday, October 26, 2010
Server Application Unavailable
This was my first ASP.Net 4.0 application deployment on IIS 6.0. The website was published under "Default Web Site" that hosts other Virtual Directories too, targeting ASP.Net 1.1 & 2.0.
When I tried to access the site, I got the error:
And the event viewer said:
Looking for resolution, I came across this blog: http://weblogs.asp.net/owscott/archive/2006/01/26/436607.aspx
I rechecked and my application was using the application pool created for .Net 4.0 apps; so the issue was not with application pool. After a bit of more wandering I started checking all websites that were using the .Net 4.0 application pool. And it turned out somebody had their website use the .Net 4.0 application pool but target .Net framework 2.0. Argh!!
When I tried to access the site, I got the error:
Server Application Unavailable
The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.
Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.
And the event viewer said:
It is not possible to run two different versions of ASP.NET in the same IIS process. Please use the IIS Administration Tool to reconfigure your server to run the application in a separate process.
Looking for resolution, I came across this blog: http://weblogs.asp.net/owscott/archive/2006/01/26/436607.aspx
I rechecked and my application was using the application pool created for .Net 4.0 apps; so the issue was not with application pool. After a bit of more wandering I started checking all websites that were using the .Net 4.0 application pool. And it turned out somebody had their website use the .Net 4.0 application pool but target .Net framework 2.0. Argh!!
Thursday, October 14, 2010
The package failed to load due to error 0xC0010014
We recently got SQL Server 2008 and deployed an instance on one of our QA servers. Nothing out of the ordinary, till I tried to deploy a 2005 SSIS package on the QA server.
As usual I took SSISDeploymentManifest file, right click and selected Deploy. I was doing a file system deployment, so the first thing out of ordinary that I noticed was, the installer gave me SQL 2008 deployment path; which I assumed was okay as the 2008 installation may have overwritten some registry default value. So I selected the path where I wanted it to be and rest of the process went without a problem.
Now when I go to SQL 2005 to create a job process for the package, it gives me the error
It turned out the default SSIS installer launched was for SQL 2008 and it didn't read anything from the manifest to identify which installer it should invoke (like Visual studio does).
The way to deploy SSIS packages in such scenarios is to right click and go to "Open With". The interesting thing here was that both options listed here are : "SQL Server 2005 Integration Services Package Installation Utility". So prima-facie we won't know which one to select. I tried both and it turned out that the second option was the one that is for SQL 2005.
On a bit further investigation, I found that the "Description" on the "Version" tab of "Properties" of dtsinstall.exe is still "SQL Server 2005 Integration Services Package".
Looks like somebody at Microsoft overlooked this step of testing. :)
As usual I took SSISDeploymentManifest file, right click and selected Deploy. I was doing a file system deployment, so the first thing out of ordinary that I noticed was, the installer gave me SQL 2008 deployment path; which I assumed was okay as the 2008 installation may have overwritten some registry default value. So I selected the path where I wanted it to be and rest of the process went without a problem.
Now when I go to SQL 2005 to create a job process for the package, it gives me the error
TITLE: SSIS Execution Properties
------------------------------
The package failed to load due to error 0xC0010014 "One or more error occurred. There should be more specific errors preceding this one that explains the details of the errors. This message is used as a return value from functions that encounter errors.". This occurs when CPackage::LoadFromXML fails.
------------------------------
ADDITIONAL INFORMATION:
The package failed to load due to error 0xC0010014 "One or more error occurred. There should be more specific errors preceding this one that explains the details of the errors. This message is used as a return value from functions that encounter errors.". This occurs when CPackage::LoadFromXML fails.
It turned out the default SSIS installer launched was for SQL 2008 and it didn't read anything from the manifest to identify which installer it should invoke (like Visual studio does).
The way to deploy SSIS packages in such scenarios is to right click and go to "Open With". The interesting thing here was that both options listed here are : "SQL Server 2005 Integration Services Package Installation Utility". So prima-facie we won't know which one to select. I tried both and it turned out that the second option was the one that is for SQL 2005.
On a bit further investigation, I found that the "Description" on the "Version" tab of "Properties" of dtsinstall.exe is still "SQL Server 2005 Integration Services Package".
Looks like somebody at Microsoft overlooked this step of testing. :)
Tuesday, October 12, 2010
Login failed for user "username"
I ran into the login failed for user "username" again. This time it was different from what I had faced the first time around.
My package uses config file to get the sql credentials. When I have the package open in my IDE and add another parameter to the file it wipes out the previously saved password. So now when I try to execute the package from my IDE to test the changes, I get this dB login failure message.
What threw me off was I was looking at the connection defined in the package designer and all seemed well.
So if this happens again, you need to take a look again in the config file to check if the password value is still there.
My package uses config file to get the sql credentials. When I have the package open in my IDE and add another parameter to the file it wipes out the previously saved password. So now when I try to execute the package from my IDE to test the changes, I get this dB login failure message.
What threw me off was I was looking at the connection defined in the package designer and all seemed well.
So if this happens again, you need to take a look again in the config file to check if the password value is still there.
Monday, October 4, 2010
DateTime String patterns
Once in a while I find myself confused with which string pattern to apply to a .Net DateTime object.
I have found this web page (http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm) to be very useful and handy.
Thought of putting it here -- for my ready reference and in case somebody stumbles across this post.
And the MSDN article: http://msdn.microsoft.com/en-us/library/az4se3k1.aspx
I have found this web page (http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm) to be very useful and handy.
Thought of putting it here -- for my ready reference and in case somebody stumbles across this post.
And the MSDN article: http://msdn.microsoft.com/en-us/library/az4se3k1.aspx
Thursday, September 30, 2010
ASMX Web Service as Service Reference in VS 2010
This was an interesting thing I observed.
I started a new project on VS 2010 & .Net 4.0. For some data I had to connect to the Web Service that was build with early version of .Net framework. So I added the web service as a "Service Reference" in my project.
The web service in question has 4 overloaded search methods with "MessageName" attributes set to "search1", "search2" etc. {Not very intuitive, I know, but that's the way it is}. The one I wanted to call has the MessageName "search4".
Now when I go to my ASPX page to call the web method, I was confused not to find "search4" method listed in the intellisense. It would give me an error if I type down the method name. All the while I could see the "search4" method through my web browser.
After a bit of digging into the associated files created for each service reference, I found that in "Reference.cs" under "Reference.svcmap" this line of code:
The auto generated code explanation sounded a bit weird to me. Expose the method as it was intended by the Web service developers. Why rename them?
I started a new project on VS 2010 & .Net 4.0. For some data I had to connect to the Web Service that was build with early version of .Net framework. So I added the web service as a "Service Reference" in my project.
The web service in question has 4 overloaded search methods with "MessageName" attributes set to "search1", "search2" etc. {Not very intuitive, I know, but that's the way it is}. The one I wanted to call has the MessageName "search4".
Now when I go to my ASPX page to call the web method, I was confused not to find "search4" method listed in the intellisense. It would give me an error if I type down the method name. All the while I could see the "search4" method through my web browser.
After a bit of digging into the associated files created for each service reference, I found that in "Reference.cs" under "Reference.svcmap" this line of code:
// CODEGEN: Generating message contract since the wrapper name (search4) of message search4 does not match the default value (search3)
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/search4", ReplyAction="*")]
[System.ServiceModel.XmlSerializerFormatAttribute(SupportFaults=true)]
NS.MyProject.WS_Test.search41 search3(NS.MyProject.WS_Test.search4 request);
The auto generated code explanation sounded a bit weird to me. Expose the method as it was intended by the Web service developers. Why rename them?
Monday, September 27, 2010
An OLE DB error has occurred. Error code: 0x80040E4D. An OLE DB record is available.Hresult:Hresult: 0x80040E4D Description: "Login failed for user '
Error:
"DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E4D. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E4D Description: "Login failed for user ''."
This error is interesting in that the user name and credentials are entered correct in the SSIS Connection but you still get this error.
There are whole lot of reasons you may find on Internet. But no one sequence worked for me. What made this go away in my package was:
a.) Set "DelayValidation" to true, as I was seeking connection at run time from database/xml file.
b.) Set "Protection Level" property to "EncryptSensitiveWithPassword" and provide a package password.
I found a good explanation for various causes, though unrelated to my issue, here:
http://blogs.msdn.com/b/dataaccesstechnologies/archive/2009/11/09/ssis-error-code-dts-e-oledberror-an-ole-db-error-has-occurred-reasons-and-troubleshooting.aspx
"DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E4D. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80040E4D Description: "Login failed for user '
This error is interesting in that the user name and credentials are entered correct in the SSIS Connection but you still get this error.
There are whole lot of reasons you may find on Internet. But no one sequence worked for me. What made this go away in my package was:
a.) Set "DelayValidation" to true, as I was seeking connection at run time from database/xml file.
b.) Set "Protection Level" property to "EncryptSensitiveWithPassword" and provide a package password.
I found a good explanation for various causes, though unrelated to my issue, here:
http://blogs.msdn.com/b/dataaccesstechnologies/archive/2009/11/09/ssis-error-code-dts-e-oledberror-an-ole-db-error-has-occurred-reasons-and-troubleshooting.aspx
Wednesday, September 1, 2010
Could not find default endpoint
This was a weird error I got while trying to consume a WCF service in my web application.
My project setup was so that the service reference was made in a class library whose method, user authentication, was invoked by the web application. So the solution to this problem was that I had to have the binding information at two places:
a.) The class library that was making the call to WCF service, and
b.) The web application that was making a call to the method in class library.
A bit weird behavior in my view, but that did away with the issue.
Could not find default endpoint element that references contract 'WS_User.IUser' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
My project setup was so that the service reference was made in a class library whose method, user authentication, was invoked by the web application. So the solution to this problem was that I had to have the binding information at two places:
a.) The class library that was making the call to WCF service, and
b.) The web application that was making a call to the method in class library.
A bit weird behavior in my view, but that did away with the issue.
Monday, August 23, 2010
Could not find stored procedure 'sp_stop_job'
Deployed my SSIS package to QA and the job threw an error
Just had to modify the call to look like "msdb.dbo.sp_stop_job"
Could not find stored procedure 'sp_stop_job'.Turns out I had made the call to sp_stop_job in the current connection that was pointing to the logging database.
Just had to modify the call to look like "msdb.dbo.sp_stop_job"
Subscribe to:
Posts (Atom)