I have a bit of a quandry on my hands which hopefully you can help with.
I've been developing a Silverlight application for a client in Silverlight 4. However it became apparent that I needed to have a button to allow for full screen mode. This was fine and dandy, but when in full screen mode Silverlight 4 disables most of your keyboard inputs for security reasons....... so the reason of going full screen to make entering data into the ChildWindowForms easier then became pointless.
I should point out I can't make this application out of browser due to it having to sit inside Dynamics CRM 2011 to get the context and record id it is sitting on.
Thus began my forray into silverlight 5. This version allows for applications to run in-browser in Elevated trust mode. Previously only available as an out of browser mode.
All was going great, i had figured out that I needed to get a certificate to sign my code, add some registry keys and the user to add a certificate to trusted publishers and got it working. Awesome.
My problem arose when i tried to run my application and i got an exception like this:
There is an error in XML document (1, 41). ---> System.TypeAccessException:
Attempt by security transparent method to access security critical type failed.
At this point, all that had changed code wise was I had signed my projects with a certificate.
It seems that in Silverlight 5 It doesn't "trust" the XmlSerializer object I'm using to read in some XML configuration and deserialize into a .Net Object
After some digging it seems theres a new Serializer in town to do this for Silverlight 5, the DataContractSerializer So i thought, great I can just ammend some of the serialization code and all will be fine. Sadly not the case.
It seems that this version of the Serializer is 33% quicker in this version. The reason it is quicker, is all nodes in the XML must be in alphabetical order. If they are not in this order they are read in as null. (If they happen to be in the correct position they will be read in correctly though. )
So my question is this. Do I have no choice but to reorganize all my XML configuration files into alphabetical order to adapt to this new Serialzer, or is there a way to use the old XML serializer and make Silverlight 5 trust it?
First of all the DataContractSeriailiser isn't new to Silverlight 5 it was there before.
The nodes being in alphabetical order is, I believe, a default. The DataMemberAttribute which you can attach to each property being serialised has a Order property which you can use to dictate the order they appear in.
Related
We need to compare 2 versions of the same model in Autodesk Forge web viewer. Both 2D and 3D models, and in different formats (IFC, DWG, Revit, ...). The DiffTool extension works mostly fine, but there is a problem.
We are using the Autodesk.Forge C# library based on this example, but it is generating a "Source File" attribute for every element in the model.
This then is marked as change in every element during the comparison, which is not wanted.
I managed to track down where the attribute is coming from, and it is this line, namely the second attribute of the UploadObjectAsync function:
uploadedObj = await objects.UploadObjectAsync(input.bucketKey,
/* here -> */ Path.GetFileName(input.fileToUpload.FileName), (int)streamReader.BaseStream.Length, streamReader.BaseStream,
"application/octet-stream");
I tried to override the parameter and set it to a fixed value. That way, the "Source File" attribute would be the same and would not show as a change. But that didn't work, since the attribute is "object id", setting it to a same value as a previous model caused the new model to override the old. So even if I used the old URN, I would see the new model.
So, is there any way to solve it? Do I have abandon this C# library and do the REST API calls manually with curl or something? How to solve this?
This is nothing related to the .NET (C#) client SDK. If you submit the translation job with the direct REST API calls to Forge Model Derivative API or other client API written in different programming languages, you will still see the same property shown for IFC files.
Are you loading this model in the SVF2 format? It looks like a known issue, LMV-6829, was logged by our engineering team and reported by my colleague Petr. Our engineering team is investigating the possible solution for the Diff extension. Sorry for the inconvenience!
Using ASP.NET 4.0, IIS 7.5.
I have a website engine, I have just implemented a way for this to tell if it's being loaded on mobile and instead of loading Controls\MyControl.ascx it loads Mobile\Controls\MyControl.ascx. This works well for my controls and also my MasterPage.Master file.
What I can't figure out however is how I can do the same with Default.aspx. This needs to be done on the fly programatically as I need to be able to check if it's mobile version. I was thinking of doing something on a pre-init event in globals but not sure if that's the best way.
Note: I don't want to use inline code on Default.aspx and just display different content base on my Mobile flag as my scenario goes one step further by basing the file on customer as well and this would mean having one huge Default.aspx for all customers which wouldn't be manageable.
Changing the default document on the fly is not possible in any practical sense.
Writing to the web.config on the fly to load a mobile version of a default page is quite frankly terrible and not an answer to the true context of your issue. I would feel irresponsible as a developer if I even proposed this as an answer to loading a mobile version of a default page.
I was trying to help you solve your problem and not just answer the base question in the title. As we all know, changing the web.config will restart your application and would not serve as a true solution, as you could not do this and achieve any kind of performance.
Here is the BEST alternative (IMHO) to dealing with mobile browsers.
http://51degrees.codeplex.com/
HTH!
For anyone else looking at this I have found a solution but I am not sure I will implement it as I don't like the idea of updating the web.config file at run time. Using the Microsoft.Web.Administration namespace you can update the server.webServer -> defaultDocument section programmatically. Doing this allows you to change the path to default.aspx and it will load based on the variables you set.
This link should provide more information: http://blogs.msdn.com/b/saurabh_singh/archive/2007/11/24/accessing-iis-7-0-features-programmatically-from-configuration-file-s-c.aspx
Also, the Microsoft.Web.Administration dll isn't available directly in VS so you need to add it from %windir%\syswow64\inetsrv (64bit version).
I need get the html code this site (with C#):
http://urbs-web.curitiba.pr.gov.br/centro/defmapalinhas.asp?l=n (only works with IE8)
Using the WebClient class, or HttpWebResquest, or any other library, I do not have access to the html code generated dynamically.
So my only solution (I guess) would be to use the WebBrowser Control (WPF).
I was trying and trying, using mshtml.HTMLDocument and SHDocVw.IWebBrowser2
but it is a mess, I can not find what I want on it
it seems there are many "iframe", and inside there are more "iframe".
I do not know, I tried:
IHTMLElementCollection elcol = htmlDoc.getElementsByTagName("iframe");
var test = htmlDoc.getElementsByTagName("HTML");
var test2 = doc.all;
but had no progress, does anyone know how to help me?
Observation / trivia: This is the site that shows where all bus pass in my city. This site is horrible, and only works in IE8 has serious problems. I would like to use this information to try to create a better service, using google maps or bing maps posteriorly.
The site that I was trying to get the information is no longer available, the idea to get dynamic html source code was abandoned and I cannot found the solution using a WebBrowser Control for WPF.
I believe that today there are other ways to solve this problem.
You need to use the "Frames" object in the WebBrowser control, this object collection will return all frames and iframes if I recall correctly, and you need to look at the frames collection for each newly discovered frame you find on the page, get me? So, it’s like a recursive discovery loop that you need to run, you add each frame you find to your array or collection, and for each "unsearched" frame, you must look at that frames ".Frames" collection (they will all have a .Count etc, just a typical collection) and you do this for every newly discovered frame that you find, until of course, there are no longer any newly discovered frames that haven't had their ".Frames" collection searched.
So, the function, if done as per above, will allow for infinitely nested frames to be discovered, as I've done this in a VB6 project (I'm happy to give you the source for it if you would like it). However, the nesting is not preserved in my example, but that is ok since the nesting structure isn't important and you should figure out which was what by the order of the frames that are added to the collection since the order is related to the hierarchy of the frames being added.
Once you do that, getting the html source on this is pretty straight forward and I’m sure you know how to do, probably a .DocumentText depending on the version of the WB control you are using.
Also, you say it is not possible to use the HTTP clients to directly grab the source code? I must disagree, since once you have the frame objects, you can get the URLs from each frame object and do a URL2String type call to get the URL and turn it into a string from any httpclient-like class or framework. The only way it may be prevented on their behalf if if they accept requests only from a particular referrer (ie: the referrer must be from their domain name on some of their files etc), or the USER_AGENT where if it isn't one of the specified browsers, then it is technically possible that they will reject and not return data, unlikely but possible.
However, both referrer and user_agent can be changed in the httpclient you are using, so if they are imposing limits based on this sort of stuff, you can spoof them very easily and give them the data that they expect. Once again, this is low probability stuff, but it is possible they may have set things up this way especially if their data is proprietary.
PS: My first visit to the site ended up in IE crashing and reopening that tab :), terrible site I agree.
I have some code that prints a document using the System.Drawing.Printing namespace. This now needs to be moved into a windows service. The documentation states that this is not possible, which would support my findings so far (in that it doesn't work). I'm working under the assumption that I can get this to work by using the System.Printing namespace instead.
Here is the code that I have so far:
private Metafile myDoc;
myDoc = GetEmfDoc();
PrintServer ps = new PrintServer("\\server1\printer1");
EnumeratedPrintQueueTypes[] flags = { EnumeratedPrintQueueTypes.Local };
PrintQueueCollection queues = ps.GetPrintQueues(flags);
PrintQueue pq = queues.First<PrintQueue>();
pq.AddJob("JobName", ?);
So I want to pass myDoc to pq.AddJob(), but this doesn't seem to be possible. Using System.Drawing.Printing it was possible to simply render this on a page by page basis in the PrintDocument.PrintPage event.
Is what I'm trying to do possible, and if so, could someone point me in the right direction?
Classes within the System.Drawing.Printing namespace are not supported for use within a Windows service or ASP.NET application or service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.
It is important to understand what "not supported" means in this context. It literally means what it says, it you try to print from a service and discover a problem then you cannot call Microsoft Support and ask for help.
This is not a problem that's induced by System.Drawing, it is a generic problem with printer drivers. Chunks of code that are supplied by the printer manufacturer, not Microsoft. A significant problem with them is that they are invariably designed to be used from a desktop program. Word, Acrobat, etcetera. They readily take advantage of that, they often pop up a window to let you know that they are Working On It. Not in the least to spam the manufacturer name and reminding you that the toner cartridge is half empty. These drivers are likely to misbehave in a service. The "runtime exceptions" phrase mentioned in the note.
The worst problem with them is that they use a popup window to let you know that there's a problem. These windows are not visible when you use the printer driver from a service. So you'll have to deal with print jobs that for no discernible reason refuse to print. The "diminished service performance" phrase in the note. That's very difficult to deal with, IT staff is just powerless to have a shot at fixing the problem when they can't see any diagnostic.
Your approach doesn't solve that fundamental problem. If you really want to pursue this then contact the printer manufacturer and ask for specific advise. Don't get your hopes up, getting good answers out of hardware companies is pretty difficult.
This is a combination of permission issues and Session 0 isolation...
The following might solve the problem you face although I do NOT recommend it:
IF you really want/need to make this work you will need to make a logon (beforehand!) to the remote server (in your example server1) from inside Session 0 (NOT from the "normal" user session) - either interactively (you can switch to the session 0 desktop via rundll32 winsta.dll,WinStationSwitchToServicesSession) OR via some calls (for example using WNetAddConnection2 with the proper credentials to the remote machine, unfortunately this is usable from .NET only via p/invoke or COM using WScript.Network). The credentials used for this logon need to have full permissions regarding printing on the remote machine.
Are you running your service in an account that has the necessary rights to use the printer? More details in the Windows Services FAQ.
First, some background to my problem.
There are many versions of Internet Explorer 6 and 7 that do not support more than 20 Key-Value pairs in a cookie. I have a list of full versions that do and do not support this. This is fixed in a windows update, but it's not possible for me to force the users of my app to carry out windows update in order to use my app.
We have developed a different cookie jar for versions of Internet Explorer that do not support this, however the performance of this is not optimal, and therefore we need to only use this on versions of IE that require it.
The full version number of an IE browser is in the format 6.00.2900.2180. Everywhere I have found suggests using Request.Browser to find out browser information, but this is far too limited for my needs. To clarify this, MajorVersion returns 6, and MinorVersion returns 0, giving me 6.0 (6.0 is the version of pretty much every version of Internet Explorer 6 that exists). So what I need is the third and fourth parts (or at the very least, the third part) of the full version.
So, does anyone know of a way, in ASP.Net with C#, to find out the information I need? If someone has looked extensively into this and found it to impossible, that is fine as an answer.
You may need to revisit why you're storing so many different key-value pairs. Going low-tech, couldn't you concatenate the values into fewer or maybe even a single key? What sort of values are you storing--in a cookie?
Try grabbing the "User-Agent" request header using Request.Headers
Copying this from meandmycode to accept it as answer.
IE doesn't specify the long version
number in the user-agent header so you
have absolute no chance of detecting
this other than sending a 'snoop' page
with javascript to detect the complex
version number.. but doing something
like that is dodge city, and
javascript may not be able to find the
full version either.