473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Non-visual C# objects on a webpage are not marked as "safe for scr

Non-visual C# objects on a webpage are not marked as "safe for scripting"

I'm developing .NET components in C# which are used as ActiveX-style
controls on web pages that are displayed inside a custom browser which is
based on the IE web browser control. On 3 of about 100 PCs that the controls
have been tried on, the browser produces the following error message:

An ActiveX control on this page is not safe.
Your current security settings prohibit running unsafe controls on this
page.
As a result, this page may not display as intended.

I believe this is the "not safe for scripting" error. According to what
I've read, we shouldn't be seeing this error because the object tag which
puts the C# control on the page references a URL in the CLASSID attribute;
supposedly this type of reference automatically marks the object as safe for
scripting. However, neither adding a 'mayscript="true"' attribute to the
object tag nor implementing IObjectSafety eliminates the problem.

The problem only plagues non-visual controls, i.e., C# objects which do not
inherit from System.Windows.Forms.Control. The only step required to
alleviate the problem is to inherit from System.Windows.Forms.Control or one
of its derivatives. However, inheriting from System.ComponentModel.Component
does not eliminate the error message.

Is this the expected behavior? Is there another workaround which would
allow me to put non-visual, non-Control-derived C# classes on the web page?

I'm using v1.1 SP1 of the Framework.

Nov 16 '05 #1
4 4444
lwickland,

I would try and define the IObjectSafety interface on your objects. You
would have to define it first, but that should be a trivial matter.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"lwickland" <lw*******@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
Non-visual C# objects on a webpage are not marked as "safe for scripting"

I'm developing .NET components in C# which are used as ActiveX-style
controls on web pages that are displayed inside a custom browser which is
based on the IE web browser control. On 3 of about 100 PCs that the
controls
have been tried on, the browser produces the following error message:

An ActiveX control on this page is not safe.
Your current security settings prohibit running unsafe controls on this
page.
As a result, this page may not display as intended.

I believe this is the "not safe for scripting" error. According to what
I've read, we shouldn't be seeing this error because the object tag which
puts the C# control on the page references a URL in the CLASSID attribute;
supposedly this type of reference automatically marks the object as safe
for
scripting. However, neither adding a 'mayscript="true"' attribute to the
object tag nor implementing IObjectSafety eliminates the problem.

The problem only plagues non-visual controls, i.e., C# objects which do
not
inherit from System.Windows.Forms.Control. The only step required to
alleviate the problem is to inherit from System.Windows.Forms.Control or
one
of its derivatives. However, inheriting from
System.ComponentModel.Component
does not eliminate the error message.

Is this the expected behavior? Is there another workaround which would
allow me to put non-visual, non-Control-derived C# classes on the web
page?

I'm using v1.1 SP1 of the Framework.

Nov 16 '05 #2


"Nicholas Paldino [.NET/C# MVP]" wrote:
lwickland,

I would try and define the IObjectSafety interface on your objects. You
would have to define it first, but that should be a trivial matter.

Nicholas,

Thanks for replying.

As I noted in my original post, I have tried implementing IObjectSafety to
no avail.

I stuck MessageBox.Show()s in the methods implementing IObjectSafety to
ensure that I had implemented it correctly. On a PC that didn't display the
"safe for scripting" error, the MessageBox.Show()s were displayed as expected
when the javascript on the web page referenced the C# object. On a PC that
did display the "safe for scripting" error, the MessageBoxes weren't
displayed, indicating to me that the web page wasn't recognizing that the
object implemented IObjectSafety.

Do you have any further suggestions?

We haven't been able to find any pattern to the PCs that the problem has
appeared on; we've seen the issue on both Windows 2000 and Windows XP.

Thanks,

Leif Wickland
Nov 16 '05 #3
Hi,

Can someone show me how to implement the IObjectSafety (or any other MS
defined) interface using C#? I am new to .NET and apparently I am missing
something. Everything I've tried does not work.

Jeff Finz

"Nicholas Paldino [.NET/C# MVP]" wrote:
lwickland,

I would try and define the IObjectSafety interface on your objects. You
would have to define it first, but that should be a trivial matter.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"lwickland" <lw*******@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
Non-visual C# objects on a webpage are not marked as "safe for scripting"

I'm developing .NET components in C# which are used as ActiveX-style
controls on web pages that are displayed inside a custom browser which is
based on the IE web browser control. On 3 of about 100 PCs that the
controls
have been tried on, the browser produces the following error message:

An ActiveX control on this page is not safe.
Your current security settings prohibit running unsafe controls on this
page.
As a result, this page may not display as intended.

I believe this is the "not safe for scripting" error. According to what
I've read, we shouldn't be seeing this error because the object tag which
puts the C# control on the page references a URL in the CLASSID attribute;
supposedly this type of reference automatically marks the object as safe
for
scripting. However, neither adding a 'mayscript="true"' attribute to the
object tag nor implementing IObjectSafety eliminates the problem.

The problem only plagues non-visual controls, i.e., C# objects which do
not
inherit from System.Windows.Forms.Control. The only step required to
alleviate the problem is to inherit from System.Windows.Forms.Control or
one
of its derivatives. However, inheriting from
System.ComponentModel.Component
does not eliminate the error message.

Is this the expected behavior? Is there another workaround which would
allow me to put non-visual, non-Control-derived C# classes on the web
page?

I'm using v1.1 SP1 of the Framework.


Nov 16 '05 #4
> > As I noted in my original post, I have tried implementing
IObjectSafety to
> no avail.


IObjectSafety & friends
...


I tried implementing IObjectSafety as you've listed it here and I saw the
same "not safe for scripting" error. It's worth mentioning that my class
wasn't derived from Control or UserControl as yours was.

Thanks for the suggestion.

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Nitin Bhardwaj | last post by:
Hi all, It is said that C++ is a strongly typed language and thus a type-safe language (unlike C). So how does one explain the following behaviour : int main(void) { char *p = NULL; p = "A...
9
by: Andy Chang | last post by:
Hi, If I have this function void DoSomething(int& index) { ::Sleep(10000); DoSomethingWith(index); } Is the variable index thread safe? Meaning that if I call this from two
2
by: Jeff Chan | last post by:
I have read the documentation from msdn to try to understanding the concept of "Type safe". Would someone give me an example of code segment illustrating what is *Non* type safe? Many Thanks,...
4
by: dingoatemydonut | last post by:
The quoted text below is from comp.std.c which originated from a discussion on comp.lang.c. I've edited out the parts that do not apply to my question. Robert Gamble wrote: > Dann Corbit wrote:...
1
by: ank | last post by:
Hi, all. I've come to think of the idea of automatic initialization/deinitialization of non-local reference count pointer. I've made an assumption that the user of the pointer only read...
72
by: jacob navia | last post by:
We have discussed often the proposition from Microsoft for a safer C library. A rationale document is published here by one of the members of the design team at microsoft:...
3
by: tcomer | last post by:
Hello! I'm working on an asynchronous network application that uses multiple threads to do it's work. I have a ChatClient class that handles the basic functionality of connecting to a server and...
4
by: Jim Carlock | last post by:
http://www.php.net/downloads.php What's up with the "non-thread-safe" binaries? What exactly does non-thread-safe mean? And what are the benefits/faults? And finally, is PHP run by Microsoft?...
44
by: climber.cui | last post by:
Hi all, Does anyone have experience on the thread-safty issue with malloc()? Some people said this function provided in stdlib.h is not thread- safe, but someone said it is thread safe. Is it...
12
by: puzzlecracker | last post by:
is it even possible or/and there is a better alternative to accept input in a nonblocking manner?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.