.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Cannot convert type 'object[]' to 'byte[]'

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

I am doing this .. and i want to convert object array to byte array. How should I do that?

Object[] myVal = um.myData;

Byte[] byteArray = (Byte[])myVal;

View Complete Post

More Related Resource Links

How to convert image class object to byte type in order to insert database


I am trying to resize images after uploading and than inserting them into my database.

Dim newMainImage As System.IO.Stream = System.IO.Stream.Null
resizedMainImage.Save(newMainImage, jgpEncoder, myEncoderParameters)
Dim newMain As Image = Image.FromStream(newMainImage)

I was able to resize it however I couldnt find a way to convert image object to byte() in order to

I need something like

Dim ImageContent(newMain.ContentLength - 1) As Byte

newMain.InputStream.Read(ImageContent, 0 , newMain.ContentLength)

I need to convert image object to a file type in order to get its contentlenght and use .inputStream.Read function. Or is there any other way?

>>Object of type 'System.Boolean' cannot be converted to type 'System.Byte[]'.



I am trying to upload a picture into database using FormView insertItemTemplate. 

FormView is bounded by objectdatasource.

To upload, I placed FileUpload control inside insertItemTemplate.

In table the dataType is image.


Object of type 'System.Boolean' cannot be converted to type 'System.Byte[]'.

Any swift reply would be appreciated. Thanks.


type object parameter



I have a problem I can't figure out.

I've been trying to add a listbox with multi select enabled as a parameter to my select statement in sqldatasource.

So i created a function like this :

string strItemTypes = "";
foreach (ListItem li in lbItemType.Items)
   if (li.Selected)
      strItemTypes += "," + li.Value;
strItemTypes = strItemTypes.Substring(1);

which gives me the selected items like this for example : "1,2,3"...
Then I've been trying to add it to my sql select statement :

SELECT tblOfficesItems.idOfficesItems, tblStockItems.Name, tblStockItems.Description, tblStockItemTypes.TypeItem, tblStockItems.Notes FROM tblOfficesItems INNER JOIN tblStockItems ON tblOfficesItems.fkItem = tblStockItems.idItem INNER JOIN tblStockItemTypes ON tblStockItems.fkTypeItem = tblStockItemTypes.idTypeItem WHERE tblStockItems.fkTypeItem IN ( @fkTypeItems )

using a hiddenfield with a controlparameter of type=object
but it just don't seem to work, seems like the data just won't bind or something and I don't get any errors so I'm confused!!

then i tried this :

SELECT tblOfficesItems.idOfficesItems, tblStockItems.Name

Converting ReportDocument object into byte array ?


Hi All,

          Is it possible to convert the Report Document object as a byte array and store it in SQL , later retrieve and assing it to a report ?


Unable to cast object of type 'System.Web.Mvc.ValueProviderResult' to type 'System.IConvertible'


 Why am I getting this error on line:

               sp.Price = Convert.ToDecimal(collection.GetValue("Price"));

sp is :
  SPecials_Templates sp = new SPecials_Templates();

SPecials_Templates Defined:

    public partial class SPecials_Templates
        public class SPecials_TemplatesMetaData

            public object Key { get; set; }
            public object Template_Name { get; set; }
            public object Headline { get; set; }

Object expected error


<input type="button' onclick="timeoutCheck()" value="Click Me!" />

it tells me Microsoft JScript runtime error: Object expected


timeoutCheck() is my script function that i declared above the input tag

can anyone tell me why i am getting this error

hello i need help , any ideas are welcome i have been working on this for two weeks now and cannot seem to be able to advance

Cannot implicitly convert type


        public SqlDataReader GetModelbyModelID(int modelID)
            Database db = DatabaseFactory.CreateDatabase();
            string sqlCommand = "GetModelbyModelID";
            DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand);
            db.AddInParameter(dbCommand, "modelID", DbType.Int32, modelID);
            SqlDataReader dataReader = db.ExecuteReader(dbCommand);    ***********************
 return dataReader; }

I am getting the followind error????

Error    27    Cannot implicitly convert type 'System.Data.IDataReader' to 'System.Data.SqlClient.SqlDataReader'. An explicit conversion exists (are you missing a cast?)    E:\projects\models\App_Code\dataProfile.cs    780    40    E:\projects\models\

Related to Type Identifier in Object header

Hi , I have read some where that , every object created on CLR heap has Object Header and Object body. In case of c++ , we need to make destructor as virtual in case of polymorphism. Example c++ :-  class base {   virtual void Hello(): }; class Derived: base {   int *ptr;   Derived()  {     ptr=new int[10];   }   ~Derived()   {      delete ptr;    }    } This is not a compiled code. In this senario we need to make Derived class destructor as virtaul. Question is in case of CLR , we need  not make destructor as virtual. How does CLR takes care of this internally.    

How to convert System.Type to Data.DbType?

Hi,Is it possible to convert a System.Type to Data.DbType (this is unfortunately an enumaeration)?Thanks, Rainer.

Unable to enter the product key in the Convert License Type page (textbox is read-only)

We installed both WSS and MOSS SP2 and had planned to follow the manual fix for the known issue that the patch unexpectedly activates a trial expiration.  However, the textbox to enter the product key is read-only.  We have tried accessing this page using the normal administrator credentials as well as the farm account; no success.The SP2 issue and manual fix is detailed here, http://support.microsoft.com/default.aspx/kb/971620We were able to experience this problem on a farm running the Feb 2007 cummulative patch (version so it's not related to the SP.  But running the SP increasing the need to find the fix.Any help is appreciated,J. Aqui

How to find specific nested object type in Gridview

Dears, I have a gridview with a nested placeholder in each rows. I nested some checkboxes in each placeholders in each rows dynamically, so their ServerIDs are not the same (I dont want to use nested gridview). at the end in a button event I want to count checked checkboxes in gridview while I can not use findcontrol() method in each rows to find checkboxes due to their different ServerIDs. How can I do this?

Timer job intiation error: SharePoint cannot deserialize an object of type

Hi All, when i run a timer job (One-Time timer) it has added it to Timer Job definitions in the Central Administration. I have checked the Log file in 12 hive and found the following error..... "SharePoint cannot deserialize an object of type xyz.xyzJob, xyzTimer, Version=, Culture=neutral, PublicKeyToken=<token> on this machine. This typically occurs because the assembly containing this type is not installed on this machine. In this case, this message can be safely ignored. Otherwise, the assembly needs to be installed on this machine in a location that can be discovered by the .NET Framework." The above error says that the assembly is not added.... but it has been already added to the GAC. Can anyone guide me about the issue and how to resolve that........?

Calling a method with a class object as parameter data type.

   [WebMethod]    public string GetInfo(Customer inCust)    {        // Code in here    } I have a web service that resides on a remote server. I want to call a public method of theweb service named  "GetInfo". The method is shown above. The web service method expects a class object oftype "Customer". What I did to create a Customer object was to define in my asp.net project my own class named "Customer" which is exactlythe same as the class that belongs to the web service project on the remote server. I then created an instance of Customerand tried to call the web service passing in an object of type customer : my.Service ws = new my.Service(); // Get web service connectionCustomer aCustomer = new Customer();aCustomer.Initialize();ws.GetInfo(aCustomer) // call web service passing in a Customer object The problem is that the compiler gives me the following error: Value of type '_Default.Customer' cannot be converted to 'ws.Class1'. Here Default is refering to my Default.aspx.cs code. Why is this? Do I need to Cast my "aCustomer" class object to a type ofws.Customer ? How do I do that?

Cannot Implicitly Convert Type Ilist to List

Hi All, In the below code i get the Following Error, Cannot implicitly convert type 'System.Collections.Generic.List<Nous.nSpeckEnterprise.GetEnterpriseComponent_Result>' to 'System.Collections.Generic.IList<Nous.nSpeckEnterprise.Component>'. An explicit conversion exists (are you missing a cast?)   <br/> NSTTT_CRRISQ_TESTEntities entities = new NSTTT_CRRISQ_TESTEntities();<br/> IList<Component> Components = new List<Component>();<br/> var c = entities.GetEnterpriseComponent(componentId).ToList();<br/> <strong>Components = c;<br/> </strong> return Components;   Can anyone help me how to do teh cast.......Thanks  

Object of type Sys.UI._Time' cannot be converted to type Sys.UI._Timer

I have a main page with several menu choices, one of which launches an ajax enabled window.  The following pattern occurs: If I: 1) Launch site 2) Select menu choice listed on master page that is not ajax enabled 3) Select menu choice that launches ajax enabled popup. 4) close pages All is OK. If I repeat the steps, but in step 2 I select an ajax enabled page and them launch popup, I get the following error: Message: Sys.ArgumentTypeException: Object of type 'Sys.UI._Timer' cannot be converted to type 'Sys.UI._Timer'. I have spent days on this and have been unable to solve it.  If I remove the ajax ToolkitScriptManager and update panels from any of the pages and launch the popup, it works. Can anyone offer some guidance? that are not ajax enabled and then selethat includes an ajax enabled popup window.  T 

Weird Issue with the MOSS Search : FileExtension metadata object type instead of string

Hello, We 've got a strange issue with the search and especially with the FileExtension metadata. when we make a query on the search engine, we receive for the FileExtension metadata an unexcpected result. here is a printscreen showing the issue. http://cid-53eee937847a625e.photos.live.com/self.aspx/Public/Untitled.jpg as you can see the Type of the FileExtension is object and it should be string and I checked the type of the object and it's System.String[] the element at the index 0 contains the value! what's wrong ? thx in advance

Converting a System.Windows.Control.Image object to byte array.

Hi i need to convert a specific System.Windows.Control.Image object into an (int) array, because i'm trying to convert a silverlight application into a wpf project. private void createGi02GradBrush()<br/> {<br/> WriteableBitmap oWriteableBitmap = new WriteableBitmap(256, 256);<br/> Image oImage = new Image();<br/> oImage.Arrange(new Rect(0, 0, 256, 256));<br/> oImage.Measure(new Size(256, 256));<br/> oImage.Source = new WriteableBitmap(256, 256);<br/> Gi02GradShaderEffect oGi02GradShaderEffect = new Gi02GradShaderEffect();<br/> oGi02GradShaderEffect.pArray = oPImageBrush;<br/> oGi02GradShaderEffect.gi1GradArray = oGi1GradImageBrush;<br/> oImage.Effect = oGi02GradShaderEffect;<br/> oWriteableBitmap.Render(oImage, null);//here<br/> oWriteableBitmap.Invalidate(); <br/> this.oGi02GradImageBrush = new ImageBrush();<br/> this.oGi02GradImageBrush.ImageSource = oWriteableBitmap;<br/> } I've found some similar topics however Image object is not the same and most of its methods aren't available. Here I'm rendering a writablebitmap with a given Image object, but in wpf we need an array. oWriteableBitmap.Render(oImage, null); Any idea? Thanks. Joseph.  
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend