473,785 Members | 2,325 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MakeTypedRefere nce :error=TypedRef erences cannot be redefined as primitives.

Hi,
I have this code wich fills in data fields from a file,
recursivley down through any structures/classes
the difficulty is when I come acros a field wich is a structure,
wich can not be read as a binary blit.

I need to be able to pass this as a reference to
a function to carry on the recursion through each field...
I have tried to use TypeReferences but I get this error and
I cant find anything much about it.

public void GetFields(ref object destObj)
{
Type type = destObj.GetType ();
System.Reflecti on.FieldInfo[] fields = type.GetFields( );
foreach (System.Reflect ion.FieldInfo field in fields)
{
if(<<< tests to make sure we realy need to do this for this field
>>>>)
{
System.Reflecti on.FieldInfo[] field_s=new FieldInfo[1]{field};
TypedReference
destRef=TypedRe ference.MakeTyp edReference(des tObj,field_s);
<<<< gives exception "TypedReference s cannot be redefined as
primitives." >>>>
}
}
}

can any one shed any light or offer any other way of doing it ?
I cant find any info or make sense of it.

can my sub function return a structure that it creates somehow
with only knowing at runtime ?

I manage to do that if the structure is blitable by using PtrToStructure
as sugested by Mattius, and the rest of it works fine if I avoid structures
that
cant be blitted.

the data in the files is an existing format and is a mixture of
direct binary values and complicated conversions.

thanks
Colin =^.^=
Nov 2 '07 #1
1 2341
"colin" <co*********@nt world.NOSPAM.co mwrote in message
news:gq******** ************@ne wsfe7-gui.ntli.net...
Hi,
I have this code wich fills in data fields from a file,
recursivley down through any structures/classes
the difficulty is when I come acros a field wich is a structure,
wich can not be read as a binary blit.

I need to be able to pass this as a reference to
a function to carry on the recursion through each field...
I have tried to use TypeReferences but I get this error and
I cant find anything much about it.

public void GetFields(ref object destObj)
{
Type type = destObj.GetType ();
System.Reflecti on.FieldInfo[] fields = type.GetFields( );
foreach (System.Reflect ion.FieldInfo field in fields)
{
if(<<< tests to make sure we realy need to do this for this field
>>>)
{
System.Reflecti on.FieldInfo[] field_s=new FieldInfo[1]{field};
TypedReference
destRef=TypedRe ference.MakeTyp edReference(des tObj,field_s);
<<<< gives exception "TypedReference s cannot be redefined as
primitives." >>>>
}
}
}

can any one shed any light or offer any other way of doing it ?
I cant find any info or make sense of it.

can my sub function return a structure that it creates somehow
with only knowing at runtime ?

I manage to do that if the structure is blitable by using PtrToStructure
as sugested by Mattius, and the rest of it works fine if I avoid
structures that
cant be blitted.

the data in the files is an existing format and is a mixture of
direct binary values and complicated conversions.
seems it doesnt like it when the field is a primitive value type.
however I can avoid this case.
dont know why this should be so ?

Colin =^.^=
Nov 2 '07 #2

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

Similar topics

1
3246
by: Sorisio, Chris | last post by:
Ladies and gentlemen, I've imported some data from a MySQL database into a Python dictionary. I'm attempting to tidy up the date fields, but I'm receiving a 'mx.DateTime.Error: cannot convert value to a time value' error. It's related to glibc returning an error to a pre-1970 date, I think. My question: /how/ do I go through the Python direction I've created to remove the pre-1970 date objects? Ideally, I would be able to iterate...
8
9026
by: Kragen Sitaker | last post by:
ERROR: Cannot insert a duplicate key into unique index pg_class_relname_nsp_index We've been getting this error in our application every once in a while --- typically once an hour to once a day, although it varies over time. The daemon that gets the error exits and restarts a few seconds later. Usually it's fine then, but sometimes the error happens three or more times in a row. Occasionally, instead, we get "ERROR: Cannot insert a...
0
400
by: Matthew Louden | last post by:
I am trying to implement the sort event in data grid. I set the data grid's AllowSorting property = True. I implement the following code that should be the event will fire when the user click any of the columns in the table: Private Sub dgReport1_SortCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dgReport1.SortCommand Dim sortOrder As String = e.SortExpression.ToString()...
5
5141
by: Nathan Sokalski | last post by:
When running a page I am working on, I recieve the following error: Cannot use a leading .. to exit above the top directory. I suspect this has something to do with the problem I posted in a recent posting "HyperLink.NavigateUrl always adds an extra ../ when going to a higher level directory" on Sunday, May 29, 2005 7:33 PM However, I cannot be sure because I cannot view the generated code since it gives the error before anything is...
1
5850
by: Vycka | last post by:
Hello, There is a enterprise web application that is based on asp.net technologies and works on Microsoft IIS. The total number of users is 850. When the load of system gets very high, the system stops working and all users are receiving an error (see at the bottom). Doing IISRESET or restarting server helps (but just until the next big load). Additional information: - Server OS MS Windows Server 2003 Standard edition SP1
2
3735
by: moondaddy | last post by:
I have a simple sample site I'm building in asp.net 2.0. I created a master page and a default.aspx content page in the project's root directory. Then I created a subfolder called content and added some aspx pages in the 'content' folder. when these pages were created I referenced the master page so everything should be linked up OK. Now, back on default.aspx I added a linkbutton and referenced one of the aspx pages in the 'content'...
10
7210
by: antonis | last post by:
When I restarting my pc a warning appears with the error cannot find the file C:\winnt\system32\1.tmp Please advice me how can I solve this problem Thanks
2
3736
by: fniles | last post by:
I am using VB.NET 2005 and MS Access. I use OLEDbCommand ExecuteNonQuery to delete a record from a database. Whenever the program gets a message, it creates a new thread to process that message. In the thread I open the database, then process the message. Sometimes I get an error "Error Cannot open action query ''". Why can it execute the query and how to fix it ? Thank you. Public Class Best
0
4571
by: SMH | last post by:
Hi All, I am currently learning .Net 2, studying for 70-528. I've hit a bit of a brick wall with DataColumn.Expression. As I understand it, this can be used to (For example) concatenate two columns to make a derived column. When I run my code, I get this error: ------------
2
15862
by: sam.barker0 | last post by:
Hi , I am having 3 functions.When I step through when func b returns to funca.it throws an error "cannot find function bounds" funca() { .... ... funcb(); }
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10095
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9954
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.