7 Replies - 1861 Views - Last Post: 11 December 2012 - 06:16 AM Rate Topic: -----

#1 complete  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 104
  • Joined: 12-April 07

How does one define IOleServiceProvider in a C# WPF application?

Posted 09 December 2012 - 06:34 AM

How does one define IOleServiceProvider in a C# WPF application?


There are examples online showing how to set a WebBrowser class into silent mode in a WPF C# program:

		/// <summary>
		/// Sets the WebBrowser in silent mode so no script errors can cause
		/// interrupting popups.
		/// </summary>
		/// <param name="browser">The browser control</param>
		/// <param name="silent">Whether or not silent mode should be on</param>
		private static void SetSilent(WebBrowser browser, bool silent)
		{
			if (browser == null)
				throw new ArgumentNullException("browser");
			// get an IWebBrowser2 from the document
			IOleServiceProvider sp = browser.Document as IOleServiceProvider;
			if (sp != null)
			{
				Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046");
				Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11d0-8A3E-00C04FC9E26E");
				object webBrowser;
				sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out webBrowser);
				if (webBrowser != null)
				{
					webBrowser.GetType().InvokeMember("Silent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.PutDispProperty, null, webBrowser, new object[] { silent });
				}
			}
		}

but Visual Studio pre compiler does not understand IOleServiceProvider and a search online does not provide any answers on what namespace or reference to use.

Is This A Good Question/Topic? 0
  • +

Replies To: How does one define IOleServiceProvider in a C# WPF application?

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3549
  • View blog
  • Posts: 10,989
  • Joined: 05-May 12

Re: How does one define IOleServiceProvider in a C# WPF application?

Posted 09 December 2012 - 07:24 AM

View Postcomplete, on 09 December 2012 - 08:34 AM, said:

How does one define IOleServiceProvider in a C# WPF application?

You don't. You use the one that comes with the VS SDK.


View Postcomplete, on 09 December 2012 - 08:34 AM, said:

but Visual Studio pre compiler does not understand IOleServiceProvider

There is no pre compiler for C#. Are you sure you are using the right language?

View Postcomplete, on 09 December 2012 - 08:34 AM, said:

and a search online does not provide any answers on what namespace or reference to use.

I'm sorry to say, but even I who is known to have particularly weak google-fu managed to find it on my first try just by searching for "IOleServiceProvider". The first link Google finds points to MSDN which contains the namespace and DLL to reference:
http://msdn.microsof...(v=vs.110).aspx

This post has been edited by Skydiver: 09 December 2012 - 07:24 AM

Was This Post Helpful? -1
  • +
  • -

#3 complete  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 104
  • Joined: 12-April 07

Re: How does one define IOleServiceProvider in a C# WPF application?

Posted 09 December 2012 - 04:51 PM

View PostSkydiver, on 09 December 2012 - 07:24 AM, said:

View Postcomplete, on 09 December 2012 - 08:34 AM, said:

How does one define IOleServiceProvider in a C# WPF application?

You don't. You use the one that comes with the VS SDK.
Is there a Visual Studio SDK that comes seperate from Visual Studio?


Quote

View Postcomplete, on 09 December 2012 - 08:34 AM, said:

but Visual Studio pre compiler does not understand IOleServiceProvider
There is no pre compiler for C#. Are you sure you are using the right language?
Of course there is a pre compiler in Visual Studio. As you write code, it pre-compiles it. Jet Brains had one and Microsoft either bought it or built their own.

Quote

View Postcomplete, on 09 December 2012 - 08:34 AM, said:

and a search online does not provide any answers on what namespace or reference to use.

I'm sorry to say, but even I who is known to have particularly weak google-fu managed to find it on my first try just by searching for "IOleServiceProvider". The first link Google finds points to MSDN which contains the namespace and DLL to reference:
http://msdn.microsof...(v=vs.110).aspx


Yeah, I found that link you posted. It is useless. It does not give the name of a real namespace or class.

This post has been edited by complete: 09 December 2012 - 04:57 PM

Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3549
  • View blog
  • Posts: 10,989
  • Joined: 05-May 12

Re: How does one define IOleServiceProvider in a C# WPF application?

Posted 09 December 2012 - 05:47 PM

View Postcomplete, on 09 December 2012 - 06:51 PM, said:

Is there a Visual Studio SDK that comes seperate from Visual Studio?

Yes.

http://www.microsoft...s.aspx?id=30668

View Postcomplete, on 09 December 2012 - 06:51 PM, said:

Of course there is a pre compiler in Visual Studio. As you write code, it pre-compiles it. Jet Brains had one and Microsoft either bought it or built their own.

VS (and Jet brains) does not pre-compile. If they truly did pre-compile then if you had perfectly written code that compiles without any problems, then pressing F5 to run your code should instantly give you running code, because it the code is already compiled, but as you'll notice, a compile is still done. What is actually happening is that VS (and Jet Brains) does it's own parsing of the code so that it can do syntax checks and coloring, and update its internal symbol tables so that Intellisense will work.


View Postcomplete, on 09 December 2012 - 06:51 PM, said:

Yeah, I found that link you posted. It is useless. It does not give the name of a real namespace or class.

Seems to exist if the VS SDK is installed. Here's a screenshot of what Reflector is showing me as the contents of the assembly.
Attached Image
Was This Post Helpful? 0
  • +
  • -

#5 complete  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 104
  • Joined: 12-April 07

Re: How does one define IOleServiceProvider in a C# WPF application?

Posted 09 December 2012 - 10:54 PM

The JetBrains Resharper plugin was a precompiler and, yes, you did not get any compile errors when you used this tool. It showed the errors and the warnings as you wrote the code.

I got the sdk and installed it. I did not find the same program you are using. I do not have Reflector.
Was This Post Helpful? 0
  • +
  • -

#6 complete  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 104
  • Joined: 12-April 07

Re: How does one define IOleServiceProvider in a C# WPF application?

Posted 10 December 2012 - 03:20 AM

This is a mystery.
You said that I do not have to declare a namespace and that by just installing the Visual Studio SDK, my
program will recognize. But this has not been the case.
Posted Image
According to the snap shot of .NET Reflector, IOleServiceProvider is from the Namespace Microsoft.TeamFoundation...
But I cannot declare this:

Posted Image

Your screen shot also suggests that this class is a subset of SafeWebBrowser, but my IDE does not recognize SafeWebBrowser.
Was This Post Helpful? 0
  • +
  • -

#7 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3549
  • View blog
  • Posts: 10,989
  • Joined: 05-May 12

Re: How does one define IOleServiceProvider in a C# WPF application?

Posted 11 December 2012 - 06:10 AM

View Postcomplete, on 10 December 2012 - 12:54 AM, said:

The JetBrains Resharper plugin was a precompiler and, yes, you did not get any compile errors when you used this tool. It showed the errors and the warnings as you wrote the code.


Unless the definition of a compiler has changed, here is the definition from Wikipedia:

Quote

A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code).


If they are pre-compilers, where is the result of the transform? What you have is a parser, not a pre-compiler.

This post has been edited by Skydiver: 11 December 2012 - 06:10 AM

Was This Post Helpful? 0
  • +
  • -

#8 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3549
  • View blog
  • Posts: 10,989
  • Joined: 05-May 12

Re: How does one define IOleServiceProvider in a C# WPF application?

Posted 11 December 2012 - 06:16 AM

View Postcomplete, on 10 December 2012 - 05:20 AM, said:

You said that I do not have to declare a namespace and that by just installing the Visual Studio SDK, my
program will recognize. But this has not been the case.

I did not say you do not have declare a namespace. I said:

Quote

You don't. You use the one that comes with the VS SDK.


View Postcomplete, on 10 December 2012 - 05:20 AM, said:

Your screen shot also suggests that this class is a subset of SafeWebBrowser, but my IDE does not recognize SafeWebBrowser.

Installing the SDK does not necessary put the assemblies in the SDK in the GAC.

Did you add a reference to "Microsoft.TeamFoundation.WorkItemTracking.ControlsCore.dll" as indicated by the assembly line in the MSDN documentation?

Yes, it is an interface defined within the SafeWebBrowser class as indicated in the first line of the MSDN documentation.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1