?
Solved

Allow unsafe code

Posted on 2011-03-23
6
Medium Priority
?
1,014 Views
Last Modified: 2012-05-11
Hi Experts

I have a silverlight 4 project and i have also created a silverlight class library to write code for unsafe classes and to allow me to run this code i need the 'Allow unsafe code' option enabled and it isnt within my build properties tab of the silverlight project. Does anyone know to enable this option?

Thanks
0
Comment
Question by:razza_b
  • 3
  • 3
6 Comments
 
LVL 16

Accepted Solution

by:
Imran Javed Zia earned 2000 total points
ID: 35200109
Hi,

SilverLight do not support Unsafe code, please refer to following:
http://forums.silverlight.net/forums/p/2983/164781.aspx

Thanks
0
 
LVL 1

Author Comment

by:razza_b
ID: 35200182
So thats why that option is disabled? Is there no way around this at all?

Thanks
0
 
LVL 1

Author Comment

by:razza_b
ID: 35200244
So if i have written a class within a SL class library and then i cant reference it within a SL project than whats the point??

snippet
namespace Printing
{
    public class UnsafeNativeMethods
    {
        internal enum PrinterType
        {
            Default = 0,
            Win32 = 1,
            Repository = 2,
            Cups = 3,
            PostscriptFile = 4,
            HtmlFile = 5,
            PdfFile = 6,
            PostscriptPrinter = 7,
            TextPrinter = 8,
            TextFile = 9,
            ePrinterType_ImageBmp = 10,
            ePrinterType_ImageGif = 11,
            ePrinterType_ImageJpg = 12,
            ePrinterType_ImagePcx = 13,
            ePrinterType_ImagePng = 14,
            ePrinterType_ImageTga = 15,
            ePrinterType_ImageTifSingle = 16,
            ePrinterType_ImageTifMultiPage = 17,
            ePrinterType_ZPLPrinter = 18,
            ePrinterType_ZPLFile = 19,
            Invalid = 20,

        }
         
         internal enum DataFieldUsage
        {
            NotUsed = 0,
            Normal = 1,
            Calculated = 2,
            Parameter = 3,
            Invalid = 4,

        }

        // If the DLL changes, there is one place to change the version string.
        private const string TFORMER = "TFormer60.dll";

        [DllImport(TFORMER, CharSet = CharSet.Ansi)]
        internal  extern static IntPtr Init(IntPtr hRepository);

        [DllImport(TFORMER, CharSet = CharSet.Ansi)]
        internal  extern static int Exit(IntPtr pInstance);
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 35200283
It is disabled as SilverLight application can run on non windows os which may not proived or even may not support such things. but if you are interested in printing then you may go through these links:
http://www.davidpoll.com/2010/04/16/making-printing-easier-in-silverlight-4/
http://www.silverlightshow.net/items/Advanced-printing-in-Silverlight-4.aspx
http://www.silverlightshow.net/items/A-look-at-the-Printing-API-in-Silverlight-4.aspx

Thanks
0
 
LVL 1

Author Comment

by:razza_b
ID: 35200351
Thanks for links

My company use a third party printing DLL just for .net to print using zebra thermal printers, but they havnt done it for SL thats why im trying to create something similar to what they have, looks like i just have to find a different company who can.

Cheers!
0
 
LVL 16

Expert Comment

by:Imran Javed Zia
ID: 35200374
Wish you all the best,
If it was helpful then please mark it as Answered
Thanks
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question