I couldn't see what the method would do

C

c676228

Hi all,

This is the code I am looking at:
protected void btnExportData_OnClick(object sender, EventArgs e)
{
string s = txtExportDate.Text;

DateTime d;

if (DateTime.TryParse(s, out d))
{
RunExport(d);
}
else
{
msgView.ShowError("Please enter a valid date.");
}
}

private void RunExport(DateTime d)
{

Export.Generate((DateTime?)d, null);

msgView.ShowMessage("The export is running. Please check the ftp
site.");

}


I try to find out what RunExport rountine would do(the code was delivered by
our vendor and runexport method just export database data for a specific date
entered by an user) . So in the following code, I expect this function call
Export.Generate((DateTime?)d, null);
will tell me how the data is extracted from our system.

But when I move my mouse over this method and select "go to the definition",

I only get the following:

using System;
using System.Data;

namespace TBN.Export
{
public static class Export
{
public static DataSet BenefitOptions { get; set; }
public static int? PlanID { get; set; }
public static string PlanName { get; set; }
public static DateTime? ReportDate { get; set; }
public static DataSet UserInputs { get; set; }

public static void Generate(DateTime? useThisDate, int?
useThisPlanID);
}
}


So I don't see anything what Export.Generate would do. Can you tell where
and How I can find out what it will do. I am new to both C# and .NET.

Thanks,
 
J

Jeff Johnson

I try to find out what RunExport rountine would do(the code was delivered
by
our vendor and runexport method just export database data for a specific
date
entered by an user) . So in the following code, I expect this function
call
Export.Generate((DateTime?)d, null);
will tell me how the data is extracted from our system.

But when I move my mouse over this method and select "go to the
definition",

I only get the following:

using System;
using System.Data;

namespace TBN.Export
{
public static class Export
{
public static DataSet BenefitOptions { get; set; }
public static int? PlanID { get; set; }
public static string PlanName { get; set; }
public static DateTime? ReportDate { get; set; }
public static DataSet UserInputs { get; set; }

public static void Generate(DateTime? useThisDate, int?
useThisPlanID);
}
}


So I don't see anything what Export.Generate would do. Can you tell where
and How I can find out what it will do. I am new to both C# and .NET.

Basically, you'd need to get documentation or source code from the 3rd-party
vendor. Another option, however, is to disassemble the code in the assembly
that supplies the Export class. You can do this with Reflector
(http://www.red-gate.com/products/reflector). As long as the vendor didn't
use an obfuscator, you should be able to get some pretty readable code.
 
S

Steven Cheng

Hi Betty,

If the component class is provided by 3rd party(in its own assembly), you
can not inspect into the source code directly, only method signature is
available.

If you do want to get some further info about the internal implemenation or
code logic of that class(or other classes in that 3rd party assembly), I
agree with Jeff that you can use the .NET Reflector tool to inspect that
assembly. Reflector can help you disassemble .NET assembly.

http://www.red-gate.com/products/reflector/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.




--------------------
 
C

c676228

Jeff and Steve,

Thank you so much. That's a great tool. I will explore the code with this
tool.
By the way, when I open this software, there is a list of .NET Framework
under a set of assemblies, but I don't whether I should pick up .NET
Framework 2.050727 or 2.0. Is there a way to find out what version our vendor
uses?

If I picked the wrong version, there should be a way to repopulate it, right?
There is ReadMe.htm, but haven't read it. Thought you might have a quick
anwser.

Jeff, just let you know that the development was done quickly and thriftily.
No development document was provided by our vendor.
 
C

c676228

Steve,

It's great. Now I can see some of the code. But when I tried to disassemble
this export.dll. I encountered a couple of messages like this:

The following assmebly name cannot be resolved automatically:
System.Configuration, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=XXXXXXXXXXXXXX. Please select the assembly file manually:
%SystemRoot%\Microsoft.net\Framework\v2.0.50727\System.configuration.dll ...

Does that mean I should populate with .NET Framework 2.0 instead of 2.0.50727?

Thanks.
--
Betty


"Steven Cheng" said:
Hi Betty,

If the component class is provided by 3rd party(in its own assembly), you
can not inspect into the source code directly, only method signature is
available.

If you do want to get some further info about the internal implemenation or
code logic of that class(or other classes in that 3rd party assembly), I
agree with Jeff that you can use the .NET Reflector tool to inspect that
assembly. Reflector can help you disassemble .NET assembly.

http://www.red-gate.com/products/reflector/

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.




--------------------
 
J

Jeff Johnson

The following assmebly name cannot be resolved automatically:
System.Configuration, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=XXXXXXXXXXXXXX. Please select the assembly file manually:
%SystemRoot%\Microsoft.net\Framework\v2.0.50727\System.configuration.dll
...
Does that mean I should populate with .NET Framework 2.0 instead of
2.0.50727?

2.0.50727 is the full version number of the .NET 2.0 Framework that was
released to the public (RTM). They are not two different things. Just browse
for the file in the location mentioned.

And, for reference, the public key token is exactly the same for all .NET
assemblies and for all computers. There was no need to obscure it in your
post. Even if it were your own assembly, there's no need to obscure it. It's
a PUBLIC key token, and is intended to be known by the public.
 
C

c676228

Jeff,

Thank you so much for your wonderful help. I got more information than I
expected for the PublicKeyToken part.

Now more questions come up.

How can I update those methods and code or add more code to the part I can
only see through the reflector? Do I need to cut and paste those code from
Reflector into the original class file?

What about debugging or step through this part of the code? I want to see
the result step by step just like in the regular debugging process?

I think our vendor doesn't mean to obscure the code since we own the code.
Just wondering why they deliver code differently to different part. For most
part of the code, I can see them without the help of the Reflector.

Sincerely
 
J

Jeff Johnson

Thank you so much for your wonderful help. I got more information than I
expected for the PublicKeyToken part.

Now more questions come up.

How can I update those methods and code or add more code to the part I can
only see through the reflector? Do I need to cut and paste those code from
Reflector into the original class file?

I need some clarification. Do you have the source code? Did you simply
contract this 3rd party to write code for you and you own the code
completely? (What you said below suggests that you did.) If so, are you
saying you see different code through Reflector than you see in the source
files (not counting variable names)?

The main thing to do is to be sure that you have the absolute latest, most
up-to-date version of the source code, if you have it at all.
 
C

c676228

Jeff,

Sorry I totally messed up my question.

1. Yes, we have the source code. We own the code completely. But the code
also include certain components developed by our vendor itself. I can see the
class definition/interface
for those components and I assume I need to use Reflector to view the source
code of their components. I don't think we own that part code.

2. The phase 1 of the project was delivered. We will soon maintain and
develop the software internally. But currently, if we need to update(add or
fix bug) the software, we need to contact our vendor to do it before we fully
develope it ourselves. So it is yes to your second question. They are
maitaining the software for now. I can have the most latest version anytime I
want. The reason I am looking at it is because I will be one of the person to
work on this software later on.

3. It is no to your third question. What I was trying to say is why most of
the code delivered I can see it direclty from vs 2005, while another very
small part of the code cannot be seen directly and I have to use Reflector to
disassemble it.

Thank you so much. :=))
 
J

Jeff Johnson

3. It is no to your third question. What I was trying to say is why most
of
the code delivered I can see it direclty from vs 2005, while another very
small part of the code cannot be seen directly and I have to use Reflector
to
disassemble it.

But you believe that this "small part of the code" is code you own and not
part of the 3rd-party components you referred to? If so, then it's very
strange that you would not be able to see this code during debugging.
 
C

c676228

Thak you so much Jeff and Steve. It's a wonderfule help.

I talked to our vendor already and they delivered the missing part of the
code.
It seems that a complete different project. It has its own solution file.

Does that mean if I modify this part of code and after I rebuilt. I need to
replace the same dll file in their original delivery? Or is there any other
way?
Thanks,
 
S

Steven Cheng

Thanks for your reply Betty,

Do you mean "if you change the source code of that 3rd party component(in a
separate solution)"? If so, you definitely need to update all the other
projects which have referenced that 3rd party component so as to make sure
all of them have used the latest version of the component. This is
particularly important when some of those projects have inter-communication
rely on those 3rd party components. If some of them use the new/updated
version and some others still use the old ones, there will occur
undetermined errors.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.



--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top