Getting IIS Folder physical path inside a Windows Forms Application - winforms

This question is strictly related with Windows Forms as my task is to do this inside a SAP Business one addon using C#. My requirement is to alter some configuration values stored in a Web.Config file of a related wcf service hosted in IIS. I need to get the IIS folder path (even the default path could be like "C:\inetpub\wwwroot", looking for a way to get it without hard-coding it) inside the SAP B1 form (Think as inside of a Windows Forms).
I've tried out the suggestion posted in the Getting IIS Application filesystem path thread.
string apPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
Even if I added the System.Web reference to the project it gives me a null value, and I cant add the System.Web reference specifically to address this issue.
Also I've found Environment.SpecialFolder enum usage on MSDN but even it doesn't list IIS physical folder.
Environment.GetFolderPath(Environment.SpecialFolder.System))
Can someone suggest a workaround for this scenario? Even getting this value from the system registry would be ok.

You are trying to access the web application configuration information from IIS. That means you will need a library such as Microsoft.Web.Administration from Microsoft (part of IIS),
https://www.iis.net/learn/manage/scripting/how-to-use-microsoftwebadministration
or its open source equivalent from Jexus Manager,
https://www.nuget.org/packages/Microsoft.Web.Administration.Jexus

Related

IIS Shared Configuration Webfarm - Error when dynamically updating bindings

First time posting a question so apologies for anything I'm doing wrong.
I have a webfarm of 4 IIS servers running windows server 2016 which uses an azure file storage account for its webfiles. It also save its shared configuration files to the same azure file storage account. This webfarm is then behind an azure load balancer.
Everything works fine, until part of the website code adds an IIS binding. This then causes all the servers to display the error below:
Could not load file or assembly 'EntityFramework,...etc" The parameter
is incorrect. (Image attached for full error).
The only way to resolve this error is to clear the asp.net temporary files from the C drive of all the servers and run IISRESET on each box.
Any ideas?
So this was a mystery but the following changes have resolved the issue. I'm not sure which combination has fixed it, but this might help someone who has a similar issue.
Recreate website in IIS using new App pool.
Removed individual IIS bindings and replaced with wildcard (we had a really old-school system before where we had 100s of binding, maybe one of these was corrupted).
Thanks for your help!

Consuming Data Services from Windows Phone, versions of data schema: IExtensibleDataObject alternative?

I'm accessing Azure storage (table) from my windows phone azure app, using System.Data.Services.Client dll, via DataServiceContext.
My problem is that in my data classes I can't use IExtensibleDataObject as it's not supported in Silverlight.
Applying XmlSerializerFormat attribute also doesn't affect it, seems like it is ignored when using data services (Fiddler shows that the data is not really in XML format).
Is there a way I can prevent my app from crushing each time a new field is added to the table?
The type IExtensibleDataObject isn't available in the Silverlight Windows Phone version of WCF. If you have an error regarding this type, you should be able to regenerate the proxy class.
You can regenerate your proxy class by using the "Add Service Reference" option in the WP project on Visual Studio.
You can also use the Windows Phone service utility. Mine was found here:
C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.1\Tools\SlSvcUtil.exe

Installation Error in DotNetNuke

I am new in dotnetNuke. I am trying to install DotNetNuke_Community_05.06.02_Source.zip file.Firstle i extract it to C:\DotNetNuke. There is a release.config file created in C:\DotNetNuke\WebSite\ . Renamed it as we.config. There is another we.config file in C:\DotNetNuke\DotNetNuke_Community_05.06.02_Source\Modules\RazorHost\ renamed it to web1.config. I configured it in IIS6.0 .Created a Database in SQLServer2005 named -DotNetNuke.Changed the connection string as directed by the installation guide. When i am trying to open the installtion wizard through browser it shows an error
Server Error in '/' Application.
Configuration Error
Description: An error occurred during
the processing of a configuration file
required to service this request.
Please review the specific error
details below and modify your
configuration file appropriately.
Parser Error Message: It is an error
to use a section registered as
allowDefinition='MachineToApplication'
beyond application level. This error
can be caused by a virtual directory
not being configured as an application
in IIS.
Source Error:
Line 56: Line 57:
Line 58:
validationKey="F9D1A2D3E1D3E2F7B3D9F90FF3965ABDAC304902"
Line 60:
decryptionKey="F9D1A2D3E1D3E2F7B3D9F90FF3965ABDAC304902F8D923AC"
In order to use the source package you must compile the code in release mode before attempting to access the website.
Being new to DNN, I recommend starting with the install package which will not need compiled, or even easier, you can get DNN through the Microsoft Web Platform Installer. WPI will also take care of all the dependnacies that may need configured on your computer.
I'ld like to clarify the intention behind downloading the Source Package. Were you intending to start developing and changing the dotnetnuke framework to suit your needs or did you want to set up a website that you could build modules against on IIS?
If you're intending to develop modules, I'ld suggest downloading the Install Package, creating an IIS site under Default Web Site.
- There's no need to change connection strings if you're using the database file that's in the App_Data folder.
- All you need to do is set the Folder Permissions for Network Service or IIS_IUSRS based on what application pool you're running.
- The url to the site will be http://localhost/xxx.
There are 2 ways to build modules in DNN. The Website Project and the Web Application are two different ways. They produce source code and dll's respectively. If it's internal, any way's good. If it's external facing, you might want a little bit more speed, so go Web Application.
However, If you're intending to muck around with the DNN Core Framework and adjust things, the Source is the way to go. there's no need to adjust the settings, just open the website project up in Visual Studio and away you go.

How to display a SQL Server Report in a .net webpart for SharePoint?

Can anyone describe to me the exact steps in displaying a SQL Server Report hosted on the report server (Remote mode) in a customized webpart? I realize that there is an out of the box web part that comes with SSRS but I want to be able to have already configured webparts that display specific reports available for users to add in their edit site modes. Essentially, the goal is to have a report such as 'Assigned Hours' as a web part itself, and anyone interested in displaying Assigned Hours need only click on Site Actions, Edit Page, Add Web Parts, and choose the Assigned Hours Web Part. No need for configuring a report server url or report path. Also, for certain reasons we would like to continue running the report server in native mode so Integrated mode with SharePoint is not an option.
So, below is a summary of my situation and what I have already tried:
Environment is WSS3.0, Microsoft SQL Server 2005
I have created a .net webpart and am attempting to add an instance of the ReportViewer control to the webpart. I have set to run in remote processing mode and have extended the abstract IReportServerCredentials class to handle the authentication.
I have made sure that the assembly is set to AllowPartiallyTrustedCallers
The project compiles fine. I place the dll in the correct wss bin folder for webparts.
When I try to view the webpart I get the site error message 'That assembly does not allow partially trusted callers.'
I've read things about registering my assembly with SQL Server, which I have tried with the CREATE ASSEMBLY SQL syntax, but that I am getting an sql query error saying that the there is already a reference to another assembly and that it can not find it in the same location.
Honestly, I don't really know enough about SQL Server and reporting services to know if I am close to getting it to work or if I have everything set up completely wrong in the first place. I have made custom webparts before and successfully deployed them to the site, so I know the problems lie in my ignorance of the SSRS and SQL Server. Has anyone else accomplished what I described early before? Thanks in advance!
I suggest using an ASP.NET ReportViewer control in your web part. These controls allow you to customize all parts you mentioned and are fairly easy to use and set-up. The one thing to watch for though with this control would be browser compatibility. Out of the box, it doesn't work too well with Firefox or Chrome. If you wanted though you could attached to the Reporting Services service which would give you the data you want back, then write a template-able control that used that structure to output the data. That option is much more complex, but allows for the format to be defined by the web part, rather than the report.

What's the benefit of deploying a war file instead of an exploded directory?

I'm configuring an installer for our product which, up until now, was distributed as a war file, usually on tomcat. Once tomcat has exploded the directory, the user has to open a properties file and set their database connection information. I'd like the installer to do this (we're using install4j) but there doesn't seem to be a built-in way to modify a text file inside a war file. I could just have the installer deploy the app as an exploded directory, which would save me the trouble here, but what do I lose by deploying like that instead of deploying the war?
It might work better to set up the database connection as a JNDI Datasource, rather than hand-editing a properties file inside the webapp/ directory. This is especially important if you want to allow users to re-deploy the application from the .WAR archive without overwriting their local configuration changes.
Of course, the JNDI setup isn't going to be trivially accomplished through the installer, either, since the mechanism used varies from app server to app server. However, any competent Java application server administrator should know how to configure a named datasource. Furthermore, by delegating responsibility to the app server, you allow your users to take advantage of connection pooling, clustering, and any other features provided by the datasource implementation bundled with their application server of choice.
Not much I would think - perhaps a bit of disk space, but if that's not a problem you'd be fine. Have you thought of having the installer generate the properties file and using a ZIP library (.WAR is really a .ZIP - rename it to a .ZIP and see what you get :) ) to replace or add it in?

Resources