I want to use the Task Scheduler Managed Wrapper in my ASP.Net project so that I can access the windows task scheduler from within my website. From what I have learned so far I need to add a reference to the assembly dll to my web.config. is that right? How do I figure out the public key token for the assembly file though? Is there any other way than using the 'sn.exe' utility, because I don't have the .net SDK installed and I unfortunately have no option of doing so on this computer. Thank you for your help!!
You shouldn't have to do anything with sn.exe or the public key token.
If you are working in a Web Site, right click your web-site in the Solution Explorer and click "Add Reference". It will create a Bin folder for you if there isn't one, then add the assembly to the bin.
If you are working in a Web Application, use the Add Reference dialog by right clicking "References" in the solution explorer.
EDIT:
thank you but i am not using visual studio at all. all i have is IIS and I use notepad for editing. the server side portion of my website is written in jscript.net
You will probably be adding a Reference with the web.config then, such as:
<system.web>
<assemblies>
<add assembly="YourAssemblyNameInBin" />
</assemblies>
</system.web>
Place your assembly in the Bin, and change YourAssemblyNameInBin to the name of the assembly on disk without the extension.
You don't have to include the version, culture, and public key token of the assembly. If you want to though, you can use the sn.exe tool to display the public key token like so:
sn.exe -T "PathToAssembly"
Note that the T is capital. If the assembly is not signed - then you must omit the public key token from the reference.
Related
I am working on a farm solution in sharepoint 2013. I want to open a page in an iframe that has been passed a URL as its src.
So I made a visual webpart with a .ascx file which looks like this:
<asp:HtmlIframe id="frm2" runat="server" src="" height="600px" width="900"></asp:HtmlIframe>
And in the server side code (ascx.cs) I set the src property like this:
frm2.Src = "http://wwww.google.com";
However, I the web part generates the following error:
Web Part Error: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type SharePointProject2.Employee.Employee, SharePointProject2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b6ac6e2971e56b29 could not be found or it is not registered as safe. Correlation ID: c41f8d9d-2f85-509f-fa04-e1d0062edc96.
On going through problem I found various solutions like this to add this to a web.config file.
<Assembly Location="MyAssembly.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl Assembly="MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b7ec4bdc16ce8b2" Namespace="Myblog.WebParts" TypeName="*" />
</SafeControls>
First Of All their is no web.config file in my sharepoint project
Whenever I open the project in empty farm solution no web.config file is there.
So I manually made a web.config file which is the xml file and add some code to it.
My application when running on Windows Server R2 is working well, and all the people can view it which are there in Active Directory, but when I stop the application then the same error comes in safe mode.
Please help me understand how to open a external application (to which I have a URL) in iframe using server side code on SharePoint.
What approach should I use, with the need to use server side code and in provider hosted server?
Thanks In Advance Guys
Basant Gera
I have an ASP.NET application that runs fine on my local machine. I just uploaded it to a server using web deploy. I'm getting the following error when I try to view the site:
The following errors occurred while attempting to load the app.
- The OwinStartup attribute discovered in assembly 'Gators3' referencing startup type 'Gators3.Startup' conflicts with the attribute in assembly 'MyFirstProject2' referencing startup type 'MyFirstProject2.Startup' because they have the same FriendlyName ''. Remove or rename one of the attributes, or reference the desired type directly.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.
To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.
I tried searching the entire solution for the string "MyFirstProject2" but did not come up with anything. The message gives a couple of suggestions, but none of them mean anything to me. I don't know how to "Remove or rename one of the attributes, or reference the desired type directly," and I don't see a place in the web.config to "add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config."
I found this, but am not quite sure how to implement it. I also did find [assembly: OwinStartupAttribute(typeof(Gators3.Startup))] in my Startup.cs, but not sure what the right thing to do there is either.
The problem is that the Gators3.dll and MyFirstProject2.dll are in the same folder (I guess it is bin folder on your server) and both are using Owin middleware. If you do not need MyFirstProject2.dll then the easiest way would be to delete that assembly. If you need it, but without Owin - add following line to Web.config/app.config in your MyFirstProject2 project:
<add key="owin:AutomaticAppStartup" value="False" />
If you need to use Owin for two projects configure friendly names for both of them.
Gators3 project:
Change Owin startup attribute to something like:
attribute [assembly: OwinStartupAttribute("GatorsConfig", typeof(Gators3.Startup))]
And add following line to Web.config within appSettings section:
<add key="owin:appStartup" value="GatorsConfig" />
MyFirstProject2 project:
Change Owin startup attribute to something
like:
attribute [assembly: OwinStartupAttribute("MyFirstProject2Config", typeof(MyFirstProject2.Startup))]
And add following line to Web.config within appSettings section:
<add key="owin:appStartup" value="MyFirstProject2Config" />
I had the same issue : removing everything in the /bin folder and rebuilding the solution alone worked for me. But it could be combined with renaming your assembly attribute at the top of the startupclass, giving it a Firendly name which will help to differentiate both the startup files.
[assembly: OwinStartup("MyFriendlyNameForProject1",typeof(MyProject.Startup))]
Clear your bin folder and obj folder.Rebuild the project again and run :)
Also, if you publish a solution to Azure:
1) right click and select Publish.
2) go to Settings and expand the "File Publish Options"
3) select "Remove additional files at destination"
4) Publish
Worked for me, after deleting the files from obj and bin Folder.
Delete anything that says 'MyFirstProject2' from your bin folder and rebuild the solution, It will work.
Happens when you reference (by mistake?) a project with owin startup inside another project with owin startup. Fix - delete the reference, bin, obj folders and rebuild.
I had the same problem and i added the following tag on web config:
<appSettings>
<add key="owin:AutomaticAppStartup" value="false" />
</appSettings>
This is what I have done:
Since I have 3 projects in one solution, I had to open all bin folder of each project and delete all files there.
Build each project one by one.
Build the whole solution.
Problem solves on my part.
Remove all files in your 'bin' folder and rebuild.
Delete files Bin, Build each project one by one.
Deleted everything in the bin folder, including the roslyn folder then published, and everything worked fine.
Remove old built data in temporary files, in the following path
C:\Users\[user]\AppData\Local\Temp\Temporary ASP.NET Files\vs
In my case, I was referencing one project in the other accidentally, which is why I was getting this error after removing the one accidentally added in the main project solved the problem.
If I open ASP.NET, create a blank site, add a handler file, add a webform then on the webform add an image control and set the imageurl to handler.ashx, all works fine.
Open Visual Studio 2013 or 2015, create a class library project, delete the vb file that's created, add an ASP.NET handler and use the same code as in the above handler.ashx file, compile the code and then add a reference to that DLL from the asp.net project which copies the DLL to the bin folder. My question is, how to use that handler in the asp.net project?
Sure, in the web.config you can add to the hadlers section (not httphandlers) but if registering *.zzz as the extension and then in the imageurl of the image control. ex: "aaaaaa.zzz" it should return a jpg file because of the code in that handler but nothing happens. What am I doing wrong?
I've created a test app to replicate your issue and all works fine for me.
Here is a snippet of my handler configuration, compare it to what you have got:
<system.webServer>
<handlers>
<add name="imageHandler" verb="*" path="*.zzz" type="CustomHandlers.ImageHandler, CustomHandlers"/>
</handlers>
</system.webServer>
if this didn't work, please send the details of the error/exception you are getting.
I am not sure if it is possible to trigger a handler through a dll. What worked for me was using my handler on my local project, and then having the handler call a method from the class library project. That method can then contain all of the logic that is meant to be in your handler.
I have a asp.net application where i use System.Windows.Forms namespace reference to use web browser control.the application runs fine on local system but after hosting it shows error.
How do i embed the dll for to use in the web application.
Answering a 3 1/2 year old question is pretty weird...
I. In your web.config, add a reference to Windows.Forms
<system.web>
<compilation>
<assemblies>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
<system.web>
This only works if the referenced DLL is in the GAC. If it is not:
Create a /Bin folder in your website root.
Copy your DLL there.
Do not add a reference in web.config.
II. In your module/class, import Windows.Forms (VB: Imports / C#: using)
Imports System.Windows.Forms
You can now use the web browser control. It's a bit tricky, though.
Possible uses include: generating screenshots, AJAX crawling (#! >> _escaped_fragment_) etc
System.Windows.Forms contains classes for displaying things on the computer that the code is running on. When you are testing on your PC, it works because you run the browser on the same machine as your development server.
When running on a real server, anything in System.Windows.Forms would be displayed on the server - not on the user's PC. (Besides it would be displayed on a hidden desktop in the server's service session).
You shouldn't mix webforms and windows forms. Whatever you want to do - there is another way that works, that doesn't involve winforms.
Don't use System.Windows.Forms in webb applications
As previously mentioned, you cannot use WinForms controls with ASP.NET.
Use an iframe to show whatever page you're trying to display in the webbrowser control: http://www.w3schools.com/tags/tag_iframe.asp
yes, you can do it,just copy the
system.window.form
dll into your web Bin Folder
everything will work fine.
I'm trying to get a custom handler to work for a specific URL (or set of URLs) in ASP.NET 3.5.
The handler doesn't actually do anything significant yet - it just logs the request. I can post the code if anyone things it's relevant, but I really don't think it's being called at all. (In particular, for normal exceptions I get a custom error page and logging... here I'm just getting the vanilla IIS 404.)
Here's the relevant bit of the web.config file:
<system.web>
<httpHandlers>
<add verb="GET,POST" path="*.robot" validate="false"
type="CSharpInDepth.Wave.RobotHandler, CSharpInDepth"/>
</httpHandlers>
</system.web>
(Obviously there's other stuff in that section too, but I don't think it's relevant.)
Locally, running under the dev server, it works fine. On my real box, I always get a 404. Everything under the web site directory itself is the same (replicated via svn). That includes the bin directory containing CSharpInDepth.dll, which I've verified contains CSharpInDepth.Wave.RobotHandler.
I try to fetch http://csharpindepth.com/foo.robot and just get a 404.
I've tried with and without the assembly name, specific URLs or wildcarded ones... nothing's working.
I'm sure I've just missed some simple flag somewhere in the IIS configuration, but I'm blowed if I can find it...
EDIT: It's IIS version 6. Attempting to add *.robot to the ISAPI filter now...
Well if the hosting box is IIS7 in integrated pipeline you need to add it into the other bit of the config:
<system.webmodules>
....
<modules>
<add name="RobotHandler" type="CSharpInDepth.Wave.RobotHandler, CSharpInDepth"/>
</modules>
....
</system.webmodules>
If it's IIS6 then you'll need to map *.robots to the ASP.NET ISAPI DLL.
(For the non-Skeets you do this as follows)
Open up IIS admin.
Right click on
the Web site you want to configure
and select Properties form the
context menu. This will display the
Web Site Properties dialog.
Select
the Home Directory tab and click the
Configuration button. This will
display the Application
Configuration dialog box.
Click
Add.
Select the aspnet_isapi.dll
from the .NET framework directory,
the extension you want mapped and
either All Verbs, or just the ones
you want to map.
Click ok.
Jon,
You'll have to configure the IIS script mappings to pass *.robot to aspnet_isapi.dll.